Anna Maule
Anna Maule

Reputation: 280

Visual Studio: Do nuget packages get restored when I rebuild a solution?

I know I can restore my nuget packages through the Nuget Package Manager, and that nuget packages are restored if they are missing while building.

However, I was wondering if I don't have any nuget packages missing is there anything different that happens when I build or rebuild a solution in terms of what happens with the nuget packages?

Upvotes: 1

Views: 954

Answers (3)

Adam Marks
Adam Marks

Reputation: 101

If you have a project that has a lot of C++ / C# / and C++/CLI interop code you can also have projects that will call the nuget command line directly to restore packages to folders that don't have a version number in them. This is so that interop projects can get access to the contents of the nuget packages for referencing. The Nuget UI doesn't allow interop projects to include nuget packages directly in a lot of cases.

Upvotes: 1

Brett Lesnau
Brett Lesnau

Reputation: 218

Did you also disable the NuGet source for the original server? NuGet or Visual Studio is somehow aware of where a package originally came from and most likely would not require that all packages come from your local NuGet source. It can pull from multiple sources during restore.

If you disabled the original server source, I’m not sure if NuGet still tries to restore from that server based on its cached information.

Also, if no new versions of a package found, it will probably appear like a restore never happened for those packages.

Upvotes: 1

Anna Maule
Anna Maule

Reputation: 280

By doing the following experiment it seems like nuget packages don't get restored on a rebuilt if they are not missing:

  1. Restore packages from the remote nuget server
  2. Build solution
  3. Set nuget server to be a local directory that has your locally built nuget package
  4. Bring to the solution your new local nuget package
  5. Rebuild the solution
  6. New local nuget package is on the solution
  7. Run solution successfully

I don't thing the rest of the nuget packages were restored because my local folder doesn't have those nugets that came from the server

Upvotes: 1

Related Questions