问题
When i am bulding my project i see the below error.
The command "nuget restore ProjectName.csproj - PackagesDirectory ....\packages" exited with 9009.
When i clicked edit on my .csproj i see below lines of code
<Target Name="BeforeBuild">
<Exec WorkingDirectory ="$(ProjDir)" command = "nuget restore $(ProjectName) -PackagesDirectory
..\..\packages>
</Exec>
</Target>
回答1:
First, you should make sure that you have downloaded the latest nuget.exe v5.7.0 and config it full path into System Environment PATH.
1) download it and copy it into a folder
2) then open System Environment Variable PATH and config the path of local nuget.exe
into it.
Then, click all Ok option to save it.
After that, you can open CMD and type nuget
to check whether it can call nuget.exe
.
Second, close all vs instance or msbuild window, open your xxx.csproj
file of your project,
Instead, use this:
<Target Name="BeforeBuild">
<Exec WorkingDirectory="$(ProjectDir)" command = "nuget restore $(MSBuildProjectFile) -PackagesDirectory ..\packages ">
</Exec>
</Target>
Restart your project, or close to reawaken MSBuild to build your project.
It works well in my side.
回答2:
I have downloaded nuget.exe from https://www.nuget.org/downloads and copied it to C drive Windows folder, it worked.
来源:https://stackoverflow.com/questions/63711576/vs2017-build-error-the-command-nuget-restore-exited-with-code-9009