gpt4 book ai didi

c# - 如何在 Visual Studio 中启用 NuGet 包还原?

转载 作者:IT王子 更新时间:2023-10-29 03:28:43 26 4
gpt4 key购买 nike

有一个 similar post在堆栈上,但它对我的问题没有帮助,可能是因为我使用的是 Visual Studio 2015。

如何让“启用 NuGet 包还原”选项出现在 VS2015 中?

我选择了"file">“新建项目”并创建了一个空的 ASP.NET Web 应用程序。我正在寻找这个菜单选项。

enter image description here

我应该提一下,我已经在我的项目文件夹中查找了任何预先存在的 nuGet 文件,但没有。

最佳答案

花了太长时间,但我终于在 Migrating MSBuild-Integrated solutions to Automatic Package Restore 上找到了这份文件我能够使用此处描述的方法解决问题。

  1. 从解决方案中删除 '.nuget' 解决方案目录
  2. .csproj.vbproj 文件中删除对 nuget.targets 的所有引用。尽管未得到官方支持,但文档链接到 PowerShell script如果您有很多项目需要清理。我手动编辑了我的,所以我无法就我的体验提供任何反馈。

手动编辑文件时,您需要查找以下内容:

解决方案文件 (.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>

关于c# - 如何在 Visual Studio 中启用 NuGet 包还原?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27895504/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com