Nestroy
Nestroy

Reputation: 77

Is there a way to copy nuget package references from one solution to another in .net-core?

Im currently migrating some projects from asp.net to asp.net-core and have a template asp.net-core solution which i use model for all the other applications. As the template projects includes all the neccessary nuget-packages for this transition, I tried to find a way to copy my nuget configuration from one this project to another. Sadly, I couldnt find a way in .net-core to approach this wish.

I searched for a lot of ways in visual studio and online on how to do this, but couldn't find a way. In .net it was possible to copy the packages.config file into another Project as explained in this post:

Can I copy the nuget package configuration from one project to another?

There is no packages.config in .net-core anymore however.

Does anyone have a solution to this problem? It would really save a lot of time not having to install 20+ packages manually for every project I am working on.

Upvotes: 3

Views: 3797

Answers (1)

Alexandru Clonțea
Alexandru Clonțea

Reputation: 1886

You could just copy the PackageReference nodes you need to the new project. Source: https://learn.microsoft.com/en-us/nuget/consume-packages/package-references-in-project-files

<ItemGroup>
    <!-- ... -->
    <PackageReference Include="Contoso.Utility.UsefulStuff" Version="3.6.0" />
    <!-- ... -->
</ItemGroup>

Some interesting reads: What are package references and how will they help me optimise the way I deal with Nuget packages and Migrate from packages.config to PackageReference

Upvotes: 5

Related Questions