Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio: how to add nuget packages as references when doing "Restore NuGet packages"

I have downloaded all the packages using "Restore NuGet packages" that existed in packages.config

However, they do not appear in the References, so VS is not aware of them.

Is there a way to add them automatically to the reference list? Possibly in 1 step?

enter image description here

like image 276
Mindaugas Bernatavičius Avatar asked Dec 08 '25 22:12

Mindaugas Bernatavičius


1 Answers

The references are tracked as part of the project files and are usually added as part of a NuGet package's initial installation. Restoring the packages will just download them.

This means it sounds like you need to reinstall those specific packages whose references are missing.

To do this, run the Update-Package command in the Package Manager Console with the -reinstall flag on it.

Update-Package <package_name> -ProjectName MyProject -reinstall

Optionally, you can add the -Version flag if you need to stick with a version that's not the latest, just make this version number match that stored in your packages.config file.

Or alternatively, to reinstall all packages for a given project:

Update-Package -Reinstall -ProjectName <project_name>
like image 100
Reddog Avatar answered Dec 10 '25 10:12

Reddog