简体   繁体   English

Visual Studio 2012中的NuGet构建失败

[英]NuGet Build Failure In Visual Studio 2012

I've got NuGet 2.1.31002.9028 installed in Visual studio 2012. When I enable package restore and add any package (like EntityFramework) to my project, I get the following error when building the project: 我已经在Visual Studio 2012中安装了NuGet 2.1.31002.9028。启用包还原并将任何包(如EntityFramework)添加到我的项目时,在生成项目时会出现以下错误:

Error   1   The system cannot find the path specified.  ConsoleApplication1
Error   2   The command ""D:\Code\ConsoleApplication1\.nuget\nuget.exe" install "D:\Code\ConsoleApplication1\ConsoleApplication1\packages.config" -source ""  -RequireConsent -solutionDir "D:\Code\ConsoleApplication1\ "" exited with code -1.    ConsoleApplication1
Warning 3   The referenced component 'System' could not be found.   ConsoleApplication1

There's a warning like the one above for every reference. 每个参考都有类似上面的警告。 The command in the second error works fine when I run it from a command prompt. 当我从命令提示符运行命令时,第二个错误中的命令运行正常。 I have "Allow NuGet to download missing packages during build" checked and I also tried adding a EnableNuGetPackageRestore environment variable, none of which fixed the problem. 我已选中“允许NuGet在生成过程中下载缺少的软件包”,并且我还尝试添加EnableNuGetPackageRestore环境变量,但没有一个可以解决此问题。 I also don't get this problem on my other machine, which makes it even more confusing. 我在其他机器上也没有遇到这个问题,这使它更加混乱。

I appreciate any help on this, and am more than happy to provide any additional info if needed. 感谢您提供的任何帮助,如果需要,我们非常乐意提供任何其他信息。

You should try to allow NuGet to download missing packages during build : 您应该尝试允许NuGet在构建过程中下载缺少的软件包

在此处输入图片说明

I had the same issue, so it should help. 我遇到了同样的问题,因此应该有所帮助。

source: http://blog.nuget.org/20120518/package-restore-and-consent.html 来源: http : //blog.nuget.org/20120518/package-restore-and-consent.html

This is a tough one, here are few things I would have tried 这是一个艰难的过程,这是我尝试过的一些事情

  1. Create a console app and see if it repros? 创建一个控制台应用程序,然后查看是否可以再现? (without nuget package installation) (不安装nuget软件包)
  2. Is system correctly referenced in references? 参考中是否正确引用了系统? May be try removing and adding it back. 可以尝试将其删除并添加回去。
  3. Does it repro for other project types, like class library? 它可以复制其他项目类型,例如类库吗?

Hope it helps. 希望能帮助到你。

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

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