Home: NuGet restore add references and content file automatically

Created on 27 Oct 2016  路  6Comments  路  Source: NuGet/Home

When we restore NuGet packages through VS UI or run command "nuget restore Solution.sln", it only download the NuGet packages into packages folder, but doesn't add the references and contents files into project.

NuGet version: Lastest version

VS version: VS2015 with Update 3

Detailed repro steps

  1. Install a NuGet package on your project, please make sure this package will add references and content file into your project.
  2. Copy this project to another machine.
  3. When open this project on the new machine with Visual Studio, it will automatically restore the packages. You also could restore the packages through right-click solution -> Restore NuGet Packages or through the command "nuget restore Solution.sln".
  4. The packages will be downloaded into the packages folder, but the references and content files will not be added into project automatically.
  5. I need to run "Update-Package -reinstall" command in Packages Manager Console manually to reinstall the packages. Then the references and content files will be added into project.

Whether there has a way to restore packages with add references and content files into project automatically?

Restore ByDesign

Most helpful comment

Have tried latest NuGet Version 4.3.0.4, and it is not adding missing content files to project.
What plans is about this feature?

All 6 comments

I have the exact same issue with VS 2015 Professional Update 3.
First/Initial install works, but when the project is pushed to a remote repository with the content files on gitignore and cloned on another machine, the restore of the packages doesn't copy the content files to the project.
A way to do that automatically would be great. Right now it's either the command line nuget restore Solution.sln or right-click solution->Manage NuGet Packages...->uninstall Package->install Package.
So...quite bothersome.

Agree. This should be a feature. Especially from the command line. I use NuGet to managed shared header files and scripts and I need restore to really restore just like it did an install. Maybe add a nuget reinstall command?

Have tried latest NuGet Version 4.3.0.4, and it is not adding missing content files to project.
What plans is about this feature?

Any progress with this?

This is by design, nuget restore for packages.config projects, will only download the package if it's missing on disk. It cannot add reference or content file into project since it has no context for project system. It has been like this forever, you can use reinstall to workaround it.

This "design". I don't know why the NuGet team spend so many years fighting over it instead of simply providing the tooling.. 2020 and still major deficiencies.

Was this page helpful?
0 / 5 - 0 ratings