Right after a particular windows update, MSBUild has been throwing this:
The specified task executable cmd.exe could not be run. The process cannot access the file, because it is being used by another process
This issue is very persistent. I tried increasing the "maximum number of parallel project builds" but to no avail. I didn't find any other software that was restricting non-admin access to the location that is mentioned by MSBuild.
Anyone else in a similar situation?
This issue was resolved right after another Windows update.
We encountered this same issue building our C# solution from a recently updated Visual Studio 2017, on Windows 10, with McAfee virus scan active (and locked down by our IT folks).
In our case, changing the TEMP and (especially) TMP environment variables to be c:\temp instead of c:\users{username}\AppData\Local\Temp and then re-starting Visual Studio got us past this very frustrating issue.
(Our first fix attempt set TMP to c:\windows\temp but that did not resolve the issue).
Once I turned on Diagnostic logging for MSBUILD (Tools -> Options -> Projects and Solutions -> Build and Run), I noticed that my problem was with NuGet restore:
2>C:\Code\EEE\Dev\Current\Source\.nuget\NuGet.targets(92,9): error
MSB6003: The specified task executable "cmd.exe" could not be run. The
process cannot access the file 'C:\Users\myUserName\AppData\Local\Temp\
tmp271c9a670c43427c9ba44267a4152430.exec.cmd' because it is being used by
another process.
2>Done executing task "Exec" -- FAILED. (TaskId:13)
2>Done building target "RestorePackages" in project
"TTT.EEE.Tests.Unit.csproj" -- FAILED.: (TargetId:11)