从解决方案中删除 nuget 包还原 [英] remove nuget package restore from solution

查看:48
本文介绍了从解决方案中删除 nuget 包还原的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用启用 NuGet 包还原"将最近的 nuget 包还原功能添加到解决方案中:http://docs.nuget.org/docs/workflows/using-nuget-without-committing-packages

I added the recent nuget package restore feature to a solution using 'Enable NuGet Package Restore': http://docs.nuget.org/docs/workflows/using-nuget-without-committing-packages

但是它破坏了我的构建服务器,我没有时间修复它,所以我想删除它.据我所知,没有任何选项,所以我从我所有的 *.csproj 文件中手动删除了以下行:

However it broke my build server and I didn't have the time to fix it, so I wanted to remove it. There's no option for that as far as I know, so I removed the following line manually from all my *.csproj files:

<Import Project="$(SolutionDir).nuget
uget.targets" />

现在的问题是,每次我的 *.csproj 文件被检出或打开我的解决方案时,该行会自动再次添加,如果我不小心检入它会破坏我的构建:(

The problem now is that every time my *.csproj files are checked out or open my solution, the line is automatically added again, breaking my build if I accidentally check it in :(

有什么想法可以永久删除它吗?

Any ideas how I can remove it permanently?

更新:尽管下面的答案在打开解决方案时仍然不断出现,有人遇到同样的问题吗?

UPDATE: despite the answer below it still keeps coming back when opening the solution, anyone with the same problem?

推荐答案

我看起来不太好,项目文件中添加了另一个属性:

I didn't look very well, there's another property added to the project files:

<RestorePackages>true</RestorePackages>

只需从所有 *.csproj 文件中手动删除这些以及所有这些行:

Just have to remove this as well as all these lines manually from all *.csproj files:

  <Import Project="$(SolutionDir).nuget
uget.targets" />

更新:

事实证明这是一个顽固的小错误,如果您手动编辑项目文件,确保关闭解决方案并立即从项目中删除所有行,否则它们只是项目重新加载后再次添加...

Turns out it's a persistent little bugger, if you're manually editing your project files, make sure to close the solution and delete all the lines from the project at once, otherwise they're just added again once the project reloads...

更新 2:

也从解决方案根目录中删除 .nuget 文件夹

Delete the .nuget folder from the solution root too

更新 3:

更高版本的 NuGet 添加了另一个您需要删除的部分:

A later version of NuGet adds another section that you need to remove:

 <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).nugetNuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir).nugetNuGet.targets'))" />
  </Target>

更新 4

在位于 .nuget 文件夹中的 NuGet.Targets 内,还有一个部分被添加到新项目中......将其切换为 false.

Inside the NuGet.Targets located in the .nuget folder, there is another section that gets added to new projects... switch it to false.

<!-- We need to ensure packages are restored prior to assembly resolve -->
<BuildDependsOn Condition="$(RestorePackages) == 'false'">
    RestorePackages;
    $(BuildDependsOn);
</BuildDependsOn>

这篇关于从解决方案中删除 nuget 包还原的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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