Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reinstalling NuGet packages with NuGet installed as VS Extension

I would like to be able to install all of the NuGet packages in the packages.config, as per The NuGet docs. NuGet is installed as a VS Extension, and I can't seem to find nuget.exe. Is it possible to run:

nuget i packages.config -o Packages

Without maintaining a seperate copy of nuget.exe on a per project basis?

like image 554
AlexWilson Avatar asked Jul 04 '11 10:07

AlexWilson


People also ask

How do I reinstall a 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.

How do I reinstall NuGet packages in Visual Studio?

Restore packages manually using Visual StudioEnable package restore by choosing Tools > Options > NuGet Package Manager. Under Package Restore options, select Allow NuGet to download missing packages. In Solution Explorer, right click the solution and select Restore NuGet Packages.

What happens when a NuGet package is Installed?

NuGet creates a subfolder for each package identifier, then creates subfolders for each installed version of the package. NuGet installs package dependencies as required. This process might update package versions in the process, as described in Dependency Resolution.

What is the extension of NuGet package?

Put simply, a NuGet package is a single ZIP file with the . nupkg extension that contains compiled code (DLLs), other files related to that code, and a descriptive manifest that includes information like the package's version number.


2 Answers

Reinstall all packages in all projects of the current solution:

Update-Package -Reinstall 

You can find more information about reinstalling nuget packages here

like image 105
Rodolpho Brock Avatar answered Sep 22 '22 06:09

Rodolpho Brock


Warning - using

Update-Package -Reinstall 

or

Update-Package -Reinstall -IgnoreDependencies 

may remove all of your packages and package.config files!

Always make sure that you have your backups performed first.

Scenario:

  • Solution with multiple projects
  • Each contains their own Nuget entries, some with the same packages (e.g., SharpRepository, Entity Framework)
  • Now copy folder without the packages folder for "distribution" somewhere else
  • Assume the packages folder wasn't included with the distribution
  • Now try the command Update-Package -Reinstall or if you have some alpha packages and/or are sure your dependencies are good, try Update-Package -Reinstall -IgnoreDependencies

Result:
Because the packages folder doesn't exist, the entries for your packages methodically go away, too. This can surprise some people - so be careful, is all I'm saying.

like image 26
kirkpabk Avatar answered Sep 24 '22 06:09

kirkpabk