Reputation: 941
NuGet Package restore failed for project MyProject.Application: The process cannot access the file 'C:\MySolution\packages\Microsoft.Bcl.Build.1.0.21\build/Microsoft.Bcl.Build.Tasks.dll' because it is being used by another process..
Any idea how to fix this issue? Thanks.
Upvotes: 38
Views: 16290
Reputation: 481
Close Visual Studio and kill all msbuild.exe instances, Then delete Microsoft.Bcl* folders from packages folder.
Upvotes: 0
Reputation: 547
I was having lots of those while trying to restore nuget packages in the solution located on network drive. Just moving it to a local disk helped immediately
Upvotes: 0
Reputation: 1252
Try running this from an elevated command prompt:
taskkill /im devenv.exe
Upvotes: 1
Reputation: 2018
Have a look at your .csproj file. If you find tags "PropertyGroup" and "ErrorText" with contents like:
you can safely delete these lines and store the altered .csproj file. Then you should be able to rebuild your project. This worked for me in several cases.
Upvotes: 0
Reputation: 515
Restarting Visual Studio seems to work - its seems to happen if you have multiple copies of VS open at some point - close all copies and it seems to fix it - for me its always Newtonsoft.json 11.0.2 that causes the issue for some reason. Also ending task on any MSBuild processes.
If you clear the NuGet cache (or delete the .nuget\packages folder the problem does not go away, which suggests the lock is happening during the restore process.
Upvotes: 0
Reputation: 4822
In Windows Explorer went to the folder where the NuGet packages are installed for my solution
<VS Solution>\packages\
and deleted all the Microsoft.Bcl.* folders. After that could rebuild the solution without problems.
Upvotes: 54
Reputation: 1585
In my case this problem has occured after i installed an update for visual studio components.
As an option, you can try to uninstall Nuget plugin from Visual Studio, and install again (in Tools -> Extensions and Updates).
After that the problematic package successfully restored.
Upvotes: 0