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

查看:229
本文介绍了从解决方案中删除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\nuget.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\nuget.targets" />

更新:

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

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...

UPDATE2:

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

Delete the .nuget folder from the solution root too

UPDATE3:

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)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.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天全站免登陆