Emma
Emma

Reputation: 941

NuGet Package restore failed: Microsoft.Bcl.Build.Tasks.dll used by another process

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

Answers (8)

Saeid Babaei
Saeid Babaei

Reputation: 481

Close Visual Studio and kill all msbuild.exe instances, Then delete Microsoft.Bcl* folders from packages folder.

Upvotes: 0

Dmitry Duginov
Dmitry Duginov

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

StackThis
StackThis

Reputation: 1252

Try running this from an elevated command prompt:

taskkill /im devenv.exe

Upvotes: 1

wbartussek
wbartussek

Reputation: 2018

Have a look at your .csproj file. If you find tags "PropertyGroup" and "ErrorText" with contents like:

"This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}."

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

Symo
Symo

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

Victorio Berra
Victorio Berra

Reputation: 3125

Find msbuild.exe in process explorer and kill it.

Upvotes: 17

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

Fragment
Fragment

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

Related Questions