C# NuGet 以代码 -1 退出 - 结果构建失败

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11115790/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-09 16:32:19  来源:igfitidea点击:

NuGet exited with code -1 — Build failing as a result

c#asp.net-mvc-2buildnugetdotless

提问by Canters

I have installed dotless via Package Manager in VS2012 in to an existing mixed C# solution (Class libraries and MVC2 apps), however now when I build it (F5) I get the following two errors:

我已经通过 VS2012 中的包管理器将 dotless 安装到现有的混合 C# 解决方案(类库和 MVC2 应用程序)中,但是现在当我构建它 (F5) 时,我收到以下两个错误:

The command ""C:\@GitRepos\EBS\SolutionFiles\.nuget\nuget.exe" install "C:\@GitRepos\EBS\\packages.config" -source "" -o "C:\@GitRepos\EBS\SolutionFiles\packages"" exited with code -1.

命令 ""C:\@GitRepos\EBS\SolutionFiles\.nuget\nuget.exe" install "C:\@GitRepos\EBS\\packages.config" -source "" -o "C:\@GitRepos\EBS \SolutionFiles\packages"" 以代码 -1 退出。

and

The system cannot find the path specified.

该系统找不到指定的路径。

After adding dotless to the solution a ".nuget" folder with "NuGet.exe and "NuGet.targets" has been added.

向解决方案添加 dotless 后,添加了带有“NuGet.exe 和”NuGet.targets”的“.nuget”文件夹。

I have also tried adding dotless to a new MVC2 project and other than having to add a mime type to the web.config it all works well. There isn't however a ".nuget" folder.

我还尝试将 dotless 添加到新的 MVC2 项目中,除了必须将 mime 类型添加到 web.config 之外,一切都运行良好。但是没有“.nuget”文件夹。

I also noticed that the same happens if I create a new NServiceBus solution (after installing it). The paths in the message change but the error is the same.

我还注意到,如果我创建一个新的 NServiceBus 解决方案(安装后),也会发生同样的情况。消息中的路径发生了变化,但错误是相同的。

If I take

如果我拿

"C:\@GitRepos\EBS\SolutionFiles\.nuget\nuget.exe" install "C:\@GitRepos\EBS\\packages.config" -source "" -o "C:\@GitRepos\EBS\SolutionFiles\packages"

"C:\@GitRepos\EBS\SolutionFiles\.nuget\nuget.exe" 安装 "C:\@GitRepos\EBS\\packages.config" -source "" -o "C:\@GitRepos\EBS\SolutionFiles\包裹”

and run it via a command prompt then I get:

并通过命令提示符运行它,然后我得到:

All packages listed in packages.config are already installed.

package.config 中列出的所有软件包都已安装。

回答by ferventcoder

This was also likely a nuget package restore consent that you had to set. http://blog.nuget.org/20120518/package-restore-and-consent.html

这也可能是您必须设置的 nuget 包恢复同意。http://blog.nuget.org/20120518/package-restore-and-consent.html

For anyone who wants to permanently have the consent accepted, take a look at installing http://nuget.org/packages/NuGetEnablePackageRestore- it will be accepted on all machines automatically.

对于想要永久接受同意的任何人,请查看安装http://nuget.org/packages/NuGetEnablePackageRestore- 所有机器都会自动接受它。

回答by Nathan McKenzie

So after giving up on this and then a few days later looking in to it again, I found the answer. I came across david-martos.blogspot.co.uk. After opening my command prompt and finding it also said "The system cannot find the path specified"I went looking in the registry. I found in "HKEY_CURRENT_USER\Software\Microsoft\Command Processor"that there was an AutoRun key for "c:\ansi140\x64\ansicon.exe -p ". After deleting this and trying one of my NserviceBus solutions again I found it built fine. I hope this helps others.

所以在放弃这个然后几天后再次查看它之后,我找到了答案。我遇到了 david-martos.blogspot.co.uk。打开我的命令提示符并找到它后,还说"The system cannot find the path specified"我去查看注册表。我发现"HKEY_CURRENT_USER\Software\Microsoft\Command Processor"有一个 AutoRun 键用于"c:\ansi140\x64\ansicon.exe -p ". 删除它并再次尝试我的 NserviceBus 解决方案之一后,我发现它构建得很好。我希望这对其他人有帮助。

Here is a direct link to David Martos post.

这是David Martos 帖子的直接链接。

回答by Thakur Rock

Just execute the command below from NuGet Package Manager Console. It worked for me:

只需从 NuGet 包管理器控制台执行以下命令。它对我有用:

PM> Install-Package NuGetEnablePackageRestore

回答by mkimmet

I solved this problem by opening up the Package Manager Console and clicking on the "Restore" button on the warning that popped up. Here's a pick of what it looked like. This is similar to the other solutions, but from a different angle.

我通过打开包管理器控制台并单击弹出警告上的“恢复”按钮解决了这个问题。这是它的外观选择。这与其他解决方案类似,但角度不同。

enter image description here

在此处输入图片说明

回答by IveGotThePawa

For me, I had accidentally deleted the NuGet.Config file from the root of my project directory. Fortunately, I could restore it with source control.

对我来说,我不小心从我的项目目录的根目录中删除了 NuGet.Config 文件。幸运的是,我可以使用源代码控制来恢复它。

Here's the content of my file if anyone have done the same mistake as me and doesn't have a backup:

如果有人和我犯了同样的错误并且没有备份,那么这是我的文件的内容:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <config>
    <add key="repositorypath" value="NuGet Packages" />
    <add key="globalPackagesFolder" value="NuGet Packages" />
  </config>  
  <packageRestore>
    <add key="enabled" value="True" />
  </packageRestore>  
</configuration>

回答by Byron

I had the same error:

我有同样的错误:

"The command "" exited with code -1." and "The system cannot find the path specified."

"命令 "" 以代码 -1 退出。和“系统找不到指定的路径。”

I tested all the possible solutions I found and nothing worked, at the end what I did was take the NuGet.exe from another project and replace it in the project inside the .nuget folder that was generating the error and is working now.

我测试了我发现的所有可能的解决方案,但没有任何效果,最后我所做的是从另一个项目中获取 NuGet.exe,并将其替换到 .nuget 文件夹内的项目中,该文件夹正在生成错误并且现在正在工作。