如何在Visual Studio中启用NuGet程序包还原? [英] How do I enable NuGet Package Restore in Visual Studio?
问题描述
在堆栈上有一个类似的帖子,但它没有可能因为我使用的是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.
我应该提到我已经在我的项目文件夹中寻找了任何先前存在的nuGet文件,但是没有.
I should mention that I have looked for any pre-existing nuGet files in my project folder and there are none.
推荐答案
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.
- 从解决方案中删除
'.nuget'
解决方案目录 - 从
.csproj
或.vbproj
文件中删除对nuget.targets
的所有引用.尽管没有正式支持,但是如果您有很多项目需要清理,该文档将链接到 PowerShell脚本.我手动进行了手动编辑,因此无法提供有关其使用经验的任何反馈.
- Remove the
'.nuget'
solution directory along from the solution - 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>
这篇关于如何在Visual Studio中启用NuGet程序包还原?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!