Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nuget: Migrating multiple large Solutions to PackageReference

Background

I'm working on a big project with multiple large solutions. All in all we have over 400 C#-Projects. In the past we used Nuget with the packages.config file for our dependencies. Now we want to migrate all of the projects to the new PackageReference format.

Problem

I know Visual Studio provides a solution for migrating a single project from packages.config to the PackageReference format, but I'm not aware of a solution where I can migrate multiple Visual Studio Solutions at once. I don't need the compatibility check of Visual Studio, because all used packages are compatible with the new format.

Question

Is there a convenient way of migrating multiple Visual Studio Solutions at once from packages.config to the PackageReference format?

like image 892
Niklas Avatar asked Sep 11 '18 09:09

Niklas


2 Answers

Nuget: Migrating multiple large Solutions to PackageReference

To ensure the accuracy of the migration, Visual Studio and most of the extensions are provide migrating a single project from packages.config to the PackageReference format and will perform a compatibility check of Visual Studio.

If you are want to way for of migrating multiple Visual Studio Solutions at once, AFAIK, there is no such method or extension at this moment.

As workaround, I would like provide you a extension:

NuGet PackageReference Updater

Which can migrate a single solution with multiple large projects from packages.config to the PackageReference format at once. Just right-click the Solution in Solution Explorer and click Upgrade to Package References:

enter image description here

Hope this helps.

like image 82
Leo Liu-MSFT Avatar answered Oct 03 '22 18:10

Leo Liu-MSFT


I did not find the accepted answer much relevant, because the extension link is broken. I did see some repo containing a custom code to migrate, but it just did 1-1 substitution without eliminating the transitive dependencies - not good.

So, I have written my own something to automate the process of applying the built-in migration tool to all the non Asp.Net projects - https://github.com/MarkKharitonov/NuGetPCToPRMigrator

I used it to migrate a couple of hundreds projects across a few solutions.

like image 45
mark Avatar answered Oct 03 '22 17:10

mark