I have a solution with multiple projects in it. Most of the third party references are missing, yet there are packages.config file for each project. How do I get NuGet to install/update all the packages needed? Does this need to be done via command line for each project?
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.
If there's an update and the solution is opened, nuget.exe will be removed from the solution. You could automatically update nuget.exe on restore by modifying the . nuget\nuget. targets to add the above command.
As I remember in the past nuget manager did dependencies installation automatically. The package manager will show the dependencies even if they are not explicitly declared in nuspec (docs.microsoft.com/en-us/nuget/reference/…) - as they are added automaticalky.
You can use nuget.exe to restore your packages or with NuGet 2.7, or above, installed you can simply compile your solution in Visual Studio, which will also restore the missing packages.
For NuGet.exe you can run the following command for each project.
nuget install packages.config Or with NuGet 2.7 you can restore all packages in the solution using the command line.
nuget restore YourSolution.sln Both of these will pull down the packages. Your project files will not be modified however when running this command so the project should already have a reference to the NuGet packages. If this is not the case then you can use Visual Studio to install the packages.
With NuGet 2.7, and above, Visual Studio will automatically restore missing NuGet packages when you build your solution so there is no need to use NuGet.exe.
To update all the packages in your solution, first restore them, and then you can either use NuGet.exe to update the packages or from within Visual Studio you can update the packages from the Package Manager Console window, or finally you can use the Manage Packages dialog.
From the command line you can update packages in the solution to the latest version available from nuget.org.
nuget update YourSolution.sln Note that this will not run any PowerShell scripts in any NuGet packages.
From within Visual Studio you can use the Package Manager Console to also update the packages. This has the benefit that any PowerShell scripts will be run as part of the update where as using NuGet.exe will not run them. The following command will update all packages in every project to the latest version available from nuget.org.
Update-Package You can also restrict this down to one project.
Update-Package -Project YourProjectName If you want to reinstall the packages to the same versions as were previously installed then you can use the -reinstall argument with Update-Package command.
Update-Package -reinstall You can also restrict this down to one project.
Update-Package -reinstall -Project YourProjectName The -reinstall option will first uninstall and then install the package back again into a project.
Or, you can update the packages using the Manage Packages dialog.
Updates:
-reinstall If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With