Visual Studio Tooling for migrating NuGet Packages.config to PackageReference

By | April 16, 2018

Visual Studio Tooling for migrating NuGet Packages.config to PackageReference

Like project or assembly references to the projects, NuGet PackageReferences manage NuGet dependency directly within project files rather than using a separate package.config file. This helps to manage all your project dependencies consistently from a single place. If your project running with Packages.config, and you want to migrate to PackagesReference, you can now take help of Visual Studio Tooling Support.  Visual Studio now have an out of the box support for migrating existing projects based on packages.config to PackageReference node options.

Consider you have following project with set of Nuget packages references in packages.config file.

Existing Solution with Nuget Package Config

To migrate this project from the packages.config format to the PackageReference format you can follow these steps in Visual Studio 2017 Preview 3

  • Open the solution in Visual Studio

 

  • In Solution Explorer, right-click on the References node or the packages.config and then select Migrate packages.config to PackageReference option

Migrate Config To References

  • Select the respective options for migration and dependencies and review the packages compatibility issues

Migration Window

 

Tip : Keep Track of your active files inside Solution Explorer – A Quick Visual Studio Tip

Finally, click on OK. Visual Studio will take care of the migration. Post migration you can review the changes on the references node for all the nugget packages.

Migration Completed

Overall migration would also  produce a migration report with the list of packages, and issues ( if there are any).

Migration Reports

You can read more about the overall process and detailed over here 

Hope this helps.