简体   繁体   English

NuGet package 恢复失败

[英]NuGet package restore failure

After code migration in bit bucket facing issue to build the solution in visual studio.位桶中的代码迁移后面临问题以在 Visual Studio 中构建解决方案。

Error: Severity Code Description Project File Line Suppression State错误:严重性代码描述项目文件行抑制 State

Error The command ""C:...nuget\nuget.exe" restore C:\Users..\packages.config -RequireConsent -solutionDir C:\Users.." exited with code 1.错误命令“C:...nuget\nuget.exe” restore C:\Users..\packages.config -RequireConsent -solutionDir C:\Users.. 退出,代码为 1。

Severity Code Description Project File Line Suppression State Error restore: invalid arguments.严重性代码 描述 项目文件行抑制 State 错误恢复:无效 arguments。 M5Mantle.Tests M5Mantle.Tests

Tried: cleaning nuget cache, update solution package, allowed automatic download of nuget package.已尝试:清理 nuget 缓存,更新解决方案 package,允许自动下载 nuget ZEFE90A8E604A7C6B70A。

any alternative approach I can look into to resolve the issue.我可以考虑解决问题的任何替代方法。

Error The command ""C:...nuget\nuget.exe" restore C:\Users..\packages.config -RequireConsent -solutionDir C:\Users.." exited with code 1.错误命令“C:...nuget\nuget.exe” restore C:\Users..\packages.config -RequireConsent -solutionDir C:\Users.. 退出,代码为 1。

The issue is quite obvious.这个问题非常明显。 The command which shows on the error is already parsed by VS IDE. VS IDE 已经解析了错误中显示的命令。

"C:...nuget\nuget.exe" restore C:\Users..\packages.config -RequireConsent -solutionDir C:\Users..

And that is the full, direct command.这就是完整的、直接的命令。 And you can type it in CMD command to test whether it is right.并且可以在 CMD 命令中输入,测试是否正确。

You could find that:你会发现:

C:...nuget\nuget.exe is not a right, legal full path which it can find the right nuget.exe. C:...nuget\nuget.exe不是正确的、合法的完整路径,它可以找到正确的 nuget.exe。

C:\Users..\packages.config is not right. C:\Users..\packages.config不正确。 And it cannot find the packages.config of the specific project folder.并且找不到特定项目文件夹的packages.config

C:\Users.. is not a right solution folder. C:\Users..不是正确的解决方案文件夹。

So not sure whether your restore command has used some msbuild properties like $(xxx) which are missing or some sys environment variables.所以不确定您的恢复命令是否使用了一些 msbuild 属性,例如缺少的$(xxx)或一些 sys 环境变量。

So you should check your restore command very carefully and if necessary, please share it with us and csproj file so that we can find the problem in the right direction.因此,您应该非常仔细地检查您的恢复命令,如有必要,请与我们分享它和 csproj 文件,以便我们能够找到正确的方向。

As for me , I used this:至于我,我用这个:

<Target Name="test123" BeforeTargets="PrepareForBuild">
    <Exec Command="C:\xxx\nuget.exe restore $(ProjectDir)packages.config -RequireConsent -solutionDir $(SolutionDir)"></Exec>
</Target>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM