如何启用的NuGet包在Visual Studio 2015年恢复 [英] How do I Enable NuGet Package Restore in Visual Studio 2015

查看:3752
本文介绍了如何启用的NuGet包在Visual Studio 2015年恢复的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个<一个href=\"http://stackoverflow.com/questions/15435366/vs2012-enable-nuget-package-restore-disappears-missing\">similar帖子堆栈,但因为我使用Visual Studio 2015年它不会与我的问题可能帮助

There's a similar post on stack but it doesn't help with my issue possibly because I am using Visual Studio 2015.

如何获得启用的NuGet包还原选项出现在VS2015?

How do I get the "Enable NuGet Package Restore" option to appear in VS2015?

我选择文件>新建项目,并创建了一个空的ASP.NET Web应用程序即可。我正在寻找此菜单选项。

I chose File > New Project and created an empty ASP.NET Web Application. I'm looking for this menu option.

我要指出,我已经找了我的项目文件夹中的任何pre-现有的NuGet文件,有没有。

I should mention that I have looked for any pre-existing nuGet files in my project folder and there are none.

推荐答案

花了太长时间,但我终于找到这个文件<一个href=\"http://docs.nuget.org/consume/package-restore/migrating-to-automatic-package-restore\">Migrating为自动包装的MSBuild集成的解决方案恢复,我是能够解决使用此处描述的方法问题。

It took far too long but I finally found this document on Migrating MSBuild-Integrated solutions to Automatic Package Restore and I was able to resolve the issue using the methods described here.


  1. 从溶​​液一起删除'的NuGet解决方案目录

  2. 从你的 .csproj的 .vbproj <删除以 nuget.targets 所有引用/ code>文件。虽然不是正式支持,文档链接到一个 PowerShell脚本,如果你有很多需要加以清理项目的。我手动编辑用手我的,所以我不能给出关于我与它的经验任何反馈。

  1. Remove the '.nuget' solution directory along from the solution
  2. Remove all references to nuget.targets from your .csproj or .vbproj files. Though not officially supported, the document links to a PowerShell script if you have a lot of projects which need to be cleaned up. I manually edited mine by hand so I can't give any feedback regarding my experience with it.

当手工编辑您的文件,这里就是你要寻找的:

When editing your files by hand, here's what you'll be looking for:

解决方案文件(的.sln)

Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{F4AEBB8B-A367-424E-8B14-F611C9667A85}"
ProjectSection(SolutionItems) = preProject
    .nuget\NuGet.Config = .nuget\NuGet.Config
    .nuget\NuGet.exe = .nuget\NuGet.exe
    .nuget\NuGet.targets = .nuget\NuGet.targets
EndProjectSection
EndProject

项目文件(.csproj / .vbproj)

  <Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
  <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
    <PropertyGroup>
      <ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
    </PropertyGroup>
    <Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
  </Target>

这篇关于如何启用的NuGet包在Visual Studio 2015年恢复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆