{"id":131,"date":"2018-04-09T00:00:00","date_gmt":"2018-04-09T07:00:00","guid":{"rendered":"http:\/\/devblogs.microsoft.com\/nuget\/migrate-packages-config-to-package-reference"},"modified":"2018-04-09T00:00:00","modified_gmt":"2018-04-09T07:00:00","slug":"migrate-packages-config-to-package-reference","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/dotnet\/migrate-packages-config-to-package-reference\/","title":{"rendered":"Migrate to PackageReference with 3 clicks"},"content":{"rendered":"<p>Last year, we introduced the option to <a href=\"https:\/\/blog.nuget.org\/20170316\/NuGet-now-fully-integrated-into-MSBuild.html#what-about-other-project-types-that-are-not-net-core\">make PackageReference the default package management format<\/a> for managing NuGet dependencies when installing the first NuGet package for a newly created projects. With Visual Studio Version 15.7 Preview 3, we have introduced the capability to migrate existing projects that use the <code>packages.config<\/code> format to use PackageReference instead.<\/p>\n<p>Benefits of using PackageReference include:<\/p>\n<ul>\n<li>Ability to manage all project dependencies from one place (the project file).<\/li>\n<li>An uncluttered view of top-level dependencies: the project file shows only those NuGet packages you directly installed in the project.<\/li>\n<li>Faster package install\/update times.<\/li>\n<li>Better cache management with a global-packages folder instead of a solution-local packages folder.<\/li>\n<li>Fine control over dependencies and content flow such as conditionally referencing a NuGet package per target framework, configuration, platform, or other pivots.<\/li>\n<li>New features as we continue to <a href=\"https:\/\/github.com\/NuGet\/Home\/issues\/6763\">invest in PackageReference<\/a>.<\/li>\n<\/ul>\n<h2>Migrate your projects to PackageReference today!<\/h2>\n<p>To try out the new migration experience, <a href=\"https:\/\/www.visualstudio.com\/vs\/preview\/\">download Visual Studio 2017 Preview<\/a>, open a <code>packages.config<\/code> based project, right-click the <strong>References<\/strong> node in <strong>Solution Explorer<\/strong>, and select the <strong>Migrate packages.config to PackageReference&#8230;.<\/strong> command.<\/p>\n<p><em>Note that the migrator does not presently support C++, JavaScript, and ASP.NET (.NET Framework) projects.<\/em><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2019\/05\/2018.04.04.15.7Prev3.nuget_migrator-2.png\" alt=\"tryprmigrator\" \/><\/p>\n<p>The migrator analyzes the project&#8217;s existing references, calculates the dependency graph, and categorizes them into top-level and transitive dependencies.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2019\/05\/2018.04.04.15.7Prev3.nuget_migrator-2_dialog.png\" alt=\"migratordialog\" \/><\/p>\n<p>By using the <strong>Top-level<\/strong> option, you can change any package that&#8217;s categorized as a transitive dependency to be treated instead as a top-level dependency.<\/p>\n<p>The migrator also displays warnings for any potential <a href=\"https:\/\/docs.microsoft.com\/en-us\/nuget\/reference\/migrate-packages-config-to-package-reference#package-compatibility-issues\">package incompatibilities<\/a>.<\/p>\n<h3>Backup and roll back<\/h3>\n<p>Before the process begins, the migrator creates a backup of the project file and <code>packages.config<\/code> to <code>&lt;solution_root&gt;\\MigrationBackup\\&lt;unique_guid&gt;\\&lt;project_name&gt;\\<\/code>. The backup allows you to <a href=\"https:\/\/docs.microsoft.com\/en-us\/nuget\/reference\/migrate-packages-config-to-package-reference#how-to-roll-back-to-packagesconfig\">roll back to <code>packages.config<\/code><\/a> if necessary.<\/p>\n<h3>Set PackageReference as the default<\/h3>\n<p>In the NuGet options in Visual Studio (opened using the <strong>Tools &gt; NuGet Package Manager &gt; Package Manager Settings<\/strong> menu command), change the <strong>Default package management format<\/strong>&#8221; to PackageReference. When you then install a NuGet package into a project for the first time, NuGet uses the PackageReference format. Newly created projects that come with existing NuGet references using <code>packages.config<\/code> (such as WPF) must be migrated to PackageReference after project creation.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/49\/2019\/05\/trypackageref.gif\" alt=\"trypackageref\" \/><\/p>\n<h3>Limitations<\/h3>\n<p>Although we&#8217;re working to bring the PackageReference goodness to all project types and to make all packages compatible with PackageReference, migration is not presently supported for C++, JavaScript, and ASP.NET (.NET Framework) projects.<\/p>\n<p>Also, some packages are <a href=\"https:\/\/docs.microsoft.com\/en-us\/nuget\/reference\/migrate-packages-config-to-package-reference#package-compatibility-issues\">not fully compatible with PackageReference<\/a>.<\/p>\n<h3>Enhancements in the pipeline<\/h3>\n<p>We are actively working to <a href=\"https:\/\/github.com\/NuGet\/Home\/issues\/6763\">enhance PackageReference<\/a> with features such as locking the transitive dependencies, ability to consolidate package versions across projects in a solution, and more.<\/p>\n<h2>We want to hear your feedback!<\/h2>\n<p>We want NuGet to meet the evolving needs of our community. For feedback specific to the migration experience, use <a href=\"https:\/\/github.com\/NuGet\/Home\/issues\/5877\">NuGet\/Home#5877<\/a>. For anything else, hit us up at <a href=\"mailto:feedback@nuget.org\">feedback@NuGet.org<\/a>, and as always, if you run into any issues or have an idea, <a href=\"https:\/\/github.com\/Nuget\/Home\/issues\">open an issue on GitHub<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Last year, we introduced the option to make PackageReference the default package management format for managing NuGet dependencies when installing the first NuGet package for a newly created projects. With Visual Studio Version 15.7 Preview 3, we have introduced the capability to migrate existing projects that use the packages.config format to use PackageReference instead. Benefits [&hellip;]<\/p>\n","protected":false},"author":795,"featured_media":625,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[7933,7874,646],"tags":[],"class_list":["post-131","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-feature-announcement","category-nuget","category-visual-studio"],"acf":[],"blog_post_summary":"<p>Last year, we introduced the option to make PackageReference the default package management format for managing NuGet dependencies when installing the first NuGet package for a newly created projects. With Visual Studio Version 15.7 Preview 3, we have introduced the capability to migrate existing projects that use the packages.config format to use PackageReference instead. Benefits [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts\/131","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/users\/795"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/comments?post=131"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts\/131\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/media\/625"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/media?parent=131"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/categories?post=131"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/tags?post=131"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}