VS2017 Build error - The command nuget restore exited with code 9009

那年仲夏 提交于 2021-02-04 08:37:04

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!