If you are stuck on an older .NET Framework version (e.g., 4.5) due to business requirements and cannot remove the package, ensure you are on the latest version.
While this message superficially indicates a standard file-locking issue (Windows Error ERROR_SHARING_VIOLATION ), its specific association with this DLL points to deeper systemic causes rooted in MSBuild concurrency, NuGet restore mechanisms, and antivirus interference. This article explores the architecture of the Microsoft.Bcl.Build.Tasks library, why this lock occurs, and advanced resolution strategies.
⚠️ Only exclude build folders, never system directories.
Sometimes the error happens because the build process is trying to copy the DLL to the output directory multiple times. microsoft.bcl.build.tasks.dll is used by another process
Exclude the packages folder specifically from scanning.
Is this happening on a (like Azure DevOps) or a local machine ? Does it happen every time or intermittently ?
- task: NuGetCommand@2 inputs: command: 'restore' restoreSolution: '**/*.sln' If you are stuck on an older
(split restore and build):
:
MSBuild tasks that didn't shut down properly after a crash or cancelled build. ⚠️ Only exclude build folders, never system directories
: Closing all instances of Visual Studio is often the quickest way to release the file handle.
If you encounter this error on a build server (Azure DevOps, Jenkins, TeamCity), apply these additional measures: