remove nuget package restore from solution

2019-01-20 22:29发布

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

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" />

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?

15条回答
爷的心禁止访问
2楼-- · 2019-01-20 23:05

Isn't it this setting here?

Options... -> Nuget Package Manager -> [uncheck] Allow Nuget to download missing packages

enter image description here

I'm using Visual Studio Professional + Resharper 8.2

查看更多
smile是对你的礼貌
3楼-- · 2019-01-20 23:07

Nuget sucks. Just remove nugets and remove or comment package elements from packages.config in root directory of the projects where this is a problem. Use direct references into some lib folder instead.

<?xml version="1.0" encoding="utf-8"?>
  <packages>
    <!--<package id="EntityFramework" version="6.0.2" targetFramework="net45" />-->
  </packages>
查看更多
地球回转人心会变
4楼-- · 2019-01-20 23:07

Solutions currently using MSBuild-Integrated package restore can be migrated to Automatic Package Restore. From what I understand, this should help those who are encountering CI build issues. (Please correct me if I am mistaken).

Please refer to the document on the nuget website: Migrating MSBuild-Integrated solutions to use Automatic Package Restore at http://docs.nuget.org/docs/workflows/migrating-to-automatic-package-restore

There is information there for converting with and without TFS.

David Ebbo also posted some information at http://blog.davidebbo.com/2014/01/the-right-way-to-restore-nuget-packages.html

查看更多
登录 后发表回答