1

I am sometimes getting Sharing Violation error while TFS Build definition starts copying files. Mostly DLL or Exe and With WinServices. Sometimes it works perfectly and sometimes gives this error.

2018-04-20T14:40:14.7193845Z Sharing violation 2018-04-20T14:40:14.7818767Z ##[error]Process completed with exit code 4. 2018-04-20T14:40:14.7818767Z ##[section]Finishing: Deploy Artifacts

1 Answers1

0

There may be some problems in the build as projects copy themselves and their dependencies (other projects, references, NuGet packages, etc) into the same output folder.

This error occurs because you have added files to source control that should not be in there. Therefore it is downloaded from TFS and marked as read only.

Take a look at this similar question: Error VSP1737: File could not be opened due to sharing violation

You could use a .tfignore file. You will have to manually remove all of the files that have already been added. How to please refer my reply here.

Then check for *.dll and other binaries, including *.vsp files and remove them from source control.

There are two types of binaries:

  1. References - these should be done using Nuget and never included in source control or added manually.
  2. output/generated - No generated files should be added to source control.

How to use Nuget to manage dll, take a look at below tutorials:

PatrickLu-MSFT
  • 49,478
  • 5
  • 35
  • 62