Moving from NuGet Package.Config to PackageReference
Blog
  • Topics
  • Industries
  • Partners

Explore

Topics

Industries

Partners

Moving from NuGet Package.Config to PackageReference

Recently during a .Net upgrade project, we migrated NuGet packages to PackageReference. Though we have been using NuGet packages for a long time, it has been interesting to see how NuGet has changed the way of including packages without package.config. The new method keeps solutions tidier and has numerous other advantages, so it’s definitely worth checking out.

How is it different?

Here are some differences between PackageReference and traditional package inclusion:

No more packages.config in your solution

Package references are directly added in your application just like other files, so no more packages.config.

No more long lists of dependencies (my personal favorite)

Earlier, a package inclusion would include all dependent references as well, making it very difficult to spot the ones you included. Now with PackageReference, you only see the one you actually added.

Refers packages from a global repository

Packages are referred from a global repository folder instead of a local solution folder. This saves space and improves performance.

Helps distinguish between packages and other references

Visual separation is a great way to see packages.

Cost

Only compatible with Visual Studio 2017 and later

With Visual Studio 2019 already being available, I don’t feel this is a cost. Rather, it encourages you to adopt newer technologies.

Migration

For new package references in Visual Studio, you need to set Default Package Management Format to PackageReference by going to:

  • Tools > NuGet Package Manager > Package Manager Settings

Or

  • Tools > Options; Under General tab in Package Manager Settings

For existing references, you can migrate easily by right clicking on the config file, and selecting “Migrate packages.config to PackageReference…”

Conclusion

With all of the benefits and easy migration steps, it is worth switching to PackageReference.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Subscribe to the Weekly Blog Digest:

Sign Up