Hi guys,
I get this error when trying to delete the 1.0.0 and 1.1.1 of the Microsoft.Net.Compilers NuGet. Any reason why these dlls should have a lock of sorts after a build?
My build consist of a simple sln with 3 projs referencing this NuGet.
Build Server:
[10:08:10]Failed to delete file: E:\TeamCity\buildAgent\work\2b0bb63f92b6032\packages\Microsoft.Net.Compilers.1.1.1\tools\Microsoft.Build.Tasks.CodeAnalysis.dll
[10:08:10]Failed to delete file: E:\TeamCity\buildAgent\work\2b0bb63f92b6032\packages\Microsoft.Net.Compilers.1.1.1\tools\Microsoft.CodeAnalysis.CSharp.dll
[10:08:10]Failed to delete file: E:\TeamCity\buildAgent\work\2b0bb63f92b6032\packages\Microsoft.Net.Compilers.1.1.1\tools\Microsoft.CodeAnalysis.dll
Also locally:
If I try to do a git clean -xfd to remove the local packages, I get
... remove, remove , remove ....
Removing packages/Microsoft.AspNet.WebApi.Core.5.2.3/lib/net45
Removing packages/Microsoft.AspNet.WebApi.Core.5.2.3/Content
Removing packages/Microsoft.AspNet.WebApi.Core.5.2.3/Microsoft.AspNet.WebApi.Core.5.2.3.nupkg
Unlink of file 'packages/Microsoft.Net.Compilers.1.1.1/tools/Microsoft.Build.Tasks.CodeAnalysis.dll' failed. Should I try again? (y/n)
Seems this is related to msbuild keeping a lock on these files after a build (?)
The error was due to msbuild.exe still running even after builds were completed. The exe stays running just in case you need to build again, hence trying to relieve you of the pain of a startup time. This had the side effect of keeping a lock on the roslyn.dlls mentioned in this issue. Closing all instances of msbuild.exe after each build made the clean operation work as expected.
To get msbuild to close after each build, one can use the /nr:false option to msbuild.
https://msdn.microsoft.com/library/ms164311.aspx
http://stackoverflow.com/questions/3919892/msbuild-exe-staying-open-locking-files
Most helpful comment
The error was due to
msbuild.exestill running even after builds were completed. The exe stays running just in case you need to build again, hence trying to relieve you of the pain of a startup time. This had the side effect of keeping a lock on the roslyn.dlls mentioned in this issue. Closing all instances of msbuild.exe after each build made the clean operation work as expected.To get msbuild to close after each build, one can use the
/nr:falseoption to msbuild.https://msdn.microsoft.com/library/ms164311.aspx
http://stackoverflow.com/questions/3919892/msbuild-exe-staying-open-locking-files