如何在Visual Studio中启用NuGet程序包还原?

编程入门 行业动态 更新时间:2024-10-19 04:28:16
本文介绍了如何在Visual Studio中启用NuGet程序包还原?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在堆栈上有一个类似的帖子,但它没有可能因为我使用的是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 go.microsoft/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程序包还原?

    本文发布于:2023-11-14 15:01:54,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1587670.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:程序包   如何在   Studio   Visual   NuGet

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!