I just setup a new Windows Server 2008 R2 development VM in order to work on a project. Downloaded the source code from Git and hit “Rebuild Solution”. Few projects failed to build with the following error (taken from the Output window after enabling MSBuild verbosity to Detailed:
Task “Exec” “C:\Work\Github\………….\.nuget\nuget.exe” install “C:\Work\Github\…………\packages.config” -source “” -RequireConsent -solutionDir “C:\Work\Github\…………….\ “
C:\Work\Github\…….\.nuget\NuGet.targets(87,9): error : Access is denied.
C:\Work\Github\…..\.nuget\NuGet.targets(87,9): error MSB3075: The command “”C:\Work\Github\…..\.nuget\nuget.exe” install “C:\Work\Github\…..\packages.config” -source “” -RequireConsent -solutionDir “C:\Work\Github\…..\ “” exited with code 5. Please verify that you have sufficient rights to run this command.
Done executing task “Exec” — FAILED.
The NuGet executable could not be executed during the build process! I had never faced this problem before. Came across few posts on the Internet where others were facing similar problems and had recommended to change certain NuGet settings or to delete and reinstall NuGet altogether. I did all that but no use.
I manually ran the nuget.exe in a command prompt and got the same “Access is denied” error. All of a sudden, light-bulb moment I looked at the properties of the nuget.exe and that is where the answer was! See below the screen shot.
Perhaps this is Windows Server 2008 security feature but the Everyone was allowed only “Read” permission on the nuget.exe; in order for it to get executed, the caller should have the “Read & Execute” permission as well.
Granting the “Everyone” group “Read & Execute” seems to solve the problem.
I would love to hear if you know of a better way to solve this issue. Drop me a line. Thanks.
This just saved my @$$. Thanks!
> just saved my @$$
Mine too. Thank you a lot! I thought that problem is with files NuGet tries to read/create, not with the nuget.exe itself. Mindblowing stuff.
For me was the *.nuspec file missing in version control. Worked for me but not for my collegues
In my case the error was caused by Nuget.exe architecture mismatch. Migrating from MS-Build integrated package restore solved the problem: https://docs.nuget.org/consume/package-restore/migrating-to-automatic-package-restore
I have a problem while updating the nuget >> settings > getting below error
NuGet Package Manager
Access to the path ‘\NuGet.Config’ is denied. Tried giving full access and security . No luck
Did you ever solve this issue? I’m having the same problem.
Thanks, this solved my problem!
More details why this is happening:
http://stackoverflow.com/questions/12718669/why-would-visual-studio-give-access-denied-code-5-error-when-trying-to-build-so
https://cygwin.com/ml/cygwin/2015-09/msg00072.html