Boas Enkler
Boas Enkler

Reputation: 12557

Transfer nuget Packages to new solution

I've a visual studio 2015 project in a solution. I need to create a very similar project and didn't want to manually add all packages again.

So I copied the packages json and ran "Restore nuget packages" But this command only downloaods the libs and doesn't add assembly references to the project file.

Is there a command line to enforce this ?

I Know I could also copy and adjust the content of the csproj but I'm very courious if there is a built in way.

The packages.config looks like this:

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="BouncyCastle" version="1.7.0" targetFramework="net461" />
  <package id="Common.Logging" version="3.3.1" targetFramework="net461" />

[...]

Upvotes: 3

Views: 996

Answers (1)

Matt Ward
Matt Ward

Reputation: 47937

With the packages.config copied into your project you can run the following command from the Package Manager Console to reinstall the NuGet packages.

Update-Package -reinstall

You can also restrict this to one project.

Update-Package -reinstall -ProjectName MyProject

The -reinstall parameter will get NuGet to add back the assembly references to the project.

Upvotes: 3

Related Questions