Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

remove nuget package restore from solution

People also ask

How do I stop NuGet package restore?

Go to Tools -> Options -> NuGet Package Manager -> General -> Package Restore. The first option disables restore itself, while the 2nd option disables on build restore.

How do I completely remove a NuGet package?

In the solution, right click on References and Manage NuGet packages, find the "Installed" tab in the upper right. Hover over the package and the "X" will appear to uninstall.

How do I reinstall NuGet package?

Switch to the Browse tab, search for the package name, select it, then select Install). For all packages, delete the package folder, then run nuget install . For a single package, delete the package folder and use nuget install <id> to reinstall the same one.

Can I delete C :\ Users NuGet packages?

Yes, the . nuget folder is used as a cache for packages downloaded to speed up project restore and compilation. It can safely be removed.


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

<RestorePackages>true</RestorePackages>

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

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

UPDATE:

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:

Delete the .nuget folder from the solution root too

UPDATE3:

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>

Update4

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>

To disable Nuget Package Restore:

  1. Delete .nuget folder
  2. Remove specific lines from all .csproj files

Lines to remove:

<Import Project="$(SolutionDir)\.nuget\nuget.targets" />
<RestorePackages>true</RestorePackages>

Note: Make sure you do all changes in one go before reloading solution or else it will add them back.

This is based on the following article: http://bartwullems.blogspot.no/2012/08/disable-nuget-package-restore.html

Also, you might want to double-check that this option is disabled: http://docs.nuget.org/docs/workflows/using-nuget-without-committing-packages


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


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