{"id":2159,"date":"2021-11-08T10:59:15","date_gmt":"2021-11-08T18:59:15","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/dotnet\/?p=2159"},"modified":"2021-11-08T10:59:15","modified_gmt":"2021-11-08T18:59:15","slug":"announcing-nuget-6","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/dotnet\/announcing-nuget-6\/","title":{"rendered":"Announcing NuGet 6.0 &#8211; Source Mapping, Package Vulnerabilities, Faster Solution Load, Oh My!"},"content":{"rendered":"<h2>NuGet 6.0 &#8211; Source Mapping, Package Vulnerabilities, Faster Solution Load, Oh My!<\/h2>\n<p>NuGet 6.0 is included in <a href=\"https:\/\/visualstudio.microsoft.com\/downloads\/\">Visual Studio 2022<\/a> and .<a href=\"https:\/\/dotnet.microsoft.com\/download\/dotnet\/6.0\">NET 6.0<\/a> out of the box. You can also download NuGet 6.0 for Windows, macOS, and Linux as a <a href=\"https:\/\/dist.nuget.org\/win-x86-commandline\/v6.0.0\/nuget.exe\">standalone executable<\/a>.<\/p>\n<p>NuGet 6.0 is one of many releases in our .NET unification journey. Our NuGet tooling helps developers discover new .NET packages to use for their .NET applications, while making package management easier during your daily development.<\/p>\n<h2>NuGet 6.0 Highlights<\/h2>\n<p>There are many <a href=\"https:\/\/docs.microsoft.com\/nuget\/release-notes\/nuget-6.0\">new features in NuGet 6.0<\/a>:<\/p>\n<ul>\n<li>Create and use .NET 6 NuGet packages with <a href=\"#net-6-support\"><strong>.NET 6 Support<\/strong><\/a>.<\/li>\n<li>Know where your packages come from with <a href=\"#source-mapping\"><strong>Source Mapping<\/strong><\/a>.<\/li>\n<li><a href=\"#package-vulnerabilities-in-visual-studio\"><strong>View Package Vulnerabilities in Visual Studio<\/strong><\/a>.<\/li>\n<li><a href=\"#retry-backoff-behavior\"><strong>Configure retry &amp; backoff behavior<\/strong><\/a> in NuGet Clients.<\/li>\n<li><a href=\"#exclude-default-file-extensions\"><strong>Exclude Default File Extensions<\/strong><\/a> in Build Output.<\/li>\n<li>Find alternative packages with <a href=\"#improved-deprecation-information-in-visual-studio\"><strong>Improved Deprecation Information in Visual Studio<\/strong><\/a>.<\/li>\n<li><a href=\"#add-a-package-readme-in-visual-studio\"><strong>Add a package README in Visual Studio<\/strong><\/a>.<\/li>\n<li><a href=\"#faster-solution-load-branch-switching-in-visual-studio\"><strong>Faster Solution Load &amp; Branch Switching in Visual Studio<\/strong><\/a>.<\/li>\n<\/ul>\n<h3>.NET 6 Support<\/h3>\n<p>NuGet 6.0 is the first release to offer full authoring and restoring support for NuGet packages targeting .NET 6.0. You can now target the following target frameworks:<\/p>\n<ul>\n<li>net6.0<\/li>\n<li>net6.0-windows<\/li>\n<li>net6.0-android<\/li>\n<li>net6.0-ios<\/li>\n<li>net6.0-macos<\/li>\n<li>net6.0-maccatalyst<\/li>\n<li>net6.0-tvos<\/li>\n<li>net6.0-tizen<\/li>\n<\/ul>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2020\/11\/dotnet-1.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2020\/11\/dotnet-1.png\" alt=\"Image dotnet\" width=\"227\" height=\"227\" class=\"aligncenter size-full wp-image-1788\" srcset=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2020\/11\/dotnet-1.png 227w, https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2020\/11\/dotnet-1-150x150.png 150w, https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2020\/11\/dotnet-1-24x24.png 24w, https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2020\/11\/dotnet-1-48x48.png 48w, https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2020\/11\/dotnet-1-96x96.png 96w\" sizes=\"(max-width: 227px) 100vw, 227px\" \/><\/a><\/p>\n<p>If you aren\u2019t familiar with the .NET 6.0 targets today or what it will look like in the future, don\u2019t forget to check out the <a href=\"https:\/\/github.com\/dotnet\/designs\/blob\/main\/accepted\/2021\/net6.0-tfms\/net6.0-tfms.md\">.NET 6.0 TFM spec<\/a>.<\/p>\n<h3>Source Mapping<\/h3>\n<p>Earlier this year, many package managers became aware of <a href=\"https:\/\/medium.com\/@alex.birsan\/dependency-confusion-4a5d60fec610\">dependency confusion<\/a> attacks in which a user can be tricked into installing a malicious dependency instead of the one they intended to. To fortify your software supply chain against these attacks, the NuGet team has developed a new feature that allows you to map your dependencies to specific sources. Below is an example of how you can use source mapping to protect your projects.<\/p>\n<pre><code class=\"xml\">&lt;!-- Define a global packages folder for your repository. --&gt;\n&lt;!-- This is where installed packages will be stored locally. --&gt;\n&lt;config&gt;\n  &lt;add key=\"globalPackagesFolder\" value=\"globalPackagesFolder\" \/&gt;\n&lt;\/config&gt;\n\n&lt;!-- Define my package sources, nuget.org and contoso.com. --&gt;\n&lt;!-- `clear` ensures no additional sources are inherited from another config file. --&gt;\n&lt;packageSources&gt;\n  &lt;clear \/&gt;\n  &lt;!-- `key` can be any identifier for your source. --&gt;\n  &lt;add key=\"nuget.org\" value=\"https:\/\/api.nuget.org\/v3\/index.json\" \/&gt;\n  &lt;add key=\"contoso.com\" value=\"https:\/\/contoso.com\/packages\/\" \/&gt;\n&lt;\/packageSources&gt;\n\n&lt;!-- Define mappings by adding package ID patterns beneath the target source. --&gt;\n&lt;!-- Contoso.* packages will be restored from contoso.com, everything else from nuget.org. --&gt;\n&lt;packageSourceMapping&gt;\n  &lt;!-- key value for &lt;packageSource&gt; should match key values from &lt;packageSources&gt; element --&gt;\n  &lt;packageSource key=\"nuget.org\"&gt;\n    &lt;package pattern=\"*\" \/&gt;\n  &lt;\/packageSource&gt;\n  &lt;packageSource key=\"contoso.com\"&gt;\n    &lt;package pattern=\"Contoso.*\" \/&gt;\n  &lt;\/packageSource&gt;\n&lt;\/packageSourceMapping&gt;\n<\/code><\/pre>\n<p>You can read more about source mapping in our <a href=\"https:\/\/docs.microsoft.com\/nuget\/consume-packages\/package-source-mapping\">documentation<\/a>. To secure your software supply chain, you can also read our <a href=\"https:\/\/docs.microsoft.com\/nuget\/concepts\/security-best-practices\">documentation on the topic<\/a>.<\/p>\n<h3>Package Vulnerabilities in Visual Studio<\/h3>\n<p>When using the NuGet Package Manager within Visual Studio, you will now see package vulnerabilities for your packages including details such as the number and severity of vulnerabilities as well as direct links to learn more about the advisories.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2021\/10\/vulnerability-1.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/49\/2021\/10\/vulnerability-1120x189.png\" alt=\"Image vulnerability\" width=\"640\" height=\"108\" class=\"aligncenter size-large wp-image-2165\" \/><\/a><\/p>\n<h3>Retry &amp; Backoff Behavior<\/h3>\n<p>There is now a <code>NUGET_ENABLE_EXPERIMENTAL_HTTP_RETRY<\/code> flag to improve the retry &amp; backoff behavior of NuGet clients such as increasing the maximum amount of retries and increasing the delay for a more resilient experience when encountering a weaker internet connection.<\/p>\n<h3>Exclude Default File Extensions<\/h3>\n<p>You can now use the MSBuild flag <code>&lt;AllowedOutputExtensionsInPackageBuildOutputFolder&gt;<\/code> to edit the file extensions included in the build output of your package. This gives you more control over the extensions being included in your build output folder.<\/p>\n<h3>Improved Deprecation Information in Visual Studio<\/h3>\n<p>Deprecated packages in Visual Studio now include a link to the suggested alternate package to use. You can use this feature to quickly browse and install packages that are actively maintained.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2021\/10\/deprecation-1.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2021\/10\/deprecation-1-1120x345.png\" alt=\"Image deprecation\" width=\"640\" height=\"197\" class=\"aligncenter size-large wp-image-2164\" \/><\/a><\/p>\n<h3>Add a Package README in Visual Studio<\/h3>\n<p>You can now add a package README.md file directly within Visual Studio. A README helps communicate important information about your package. It is often the first item a visitor will see when visiting your package on NuGet.org. README files typically include information on:<\/p>\n<ul>\n<li>What the package does<\/li>\n<li>Why the package is useful<\/li>\n<li>How users can get started with the package<\/li>\n<li>Where users can get help or contribute to your package<\/li>\n<\/ul>\n<p>You can read more about <a href=\"https:\/\/devblogs.microsoft.com\/dotnet\/add-a-readme-to-your-nuget-package\/\">adding a README to your NuGet package on our blog<\/a>.<\/p>\n<h3>Faster Solution Load &amp; Branch Switching in Visual Studio<\/h3>\n<p>In Visual Studio 2022, NuGet has redefined the contract between NuGet package restore and common Visual Studio components to improve performance for large solutions by only calling restore once instead of multiple times. This improves the time it takes for background processes to complete significantly.<\/p>\n<p>Install <a href=\"https:\/\/visualstudio.microsoft.com\/downloads\/\">Visual Studio 2022<\/a> and let us know if you notice a faster experience when loading your large solutions or switching between branches!<\/p>\n<h2>Closing<\/h2>\n<p>NuGet 6.0 is a big release that should improve many aspects of your daily package management needs. We\u2019ve added a bunch of new features to Visual Studio experiences, improved restore performance to solution load &amp; branch switching, and added support to .NET 6!<\/p>\n<p>We\u2019re excited to see you use NuGet 6.0 &amp; include it in your toolset for building amazing things with .NET.<\/p>\n<p>For more details on NuGet 6.0, see our <a href=\"https:\/\/docs.microsoft.com\/nuget\/release-notes\/nuget-6.0\">official release notes<\/a>.<\/p>\n<h2>Feedback<\/h2>\n<p>Your feedback is important to us. If there are any problems with this release, check our <a href=\"https:\/\/github.com\/NuGet\/Home\/issues\">GitHub Issues<\/a> and <a href=\"https:\/\/developercommunity.visualstudio.com\/\">Visual Studio Developer Community<\/a> for existing issues. For new issues within NuGet, please report a <a href=\"https:\/\/github.com\/NuGet\/Home\/issues\/new\/choose\">GitHub Issue<\/a>. For general NuGet experience issues, let us know via the <a href=\"https:\/\/docs.microsoft.com\/visualstudio\/ide\/how-to-report-a-problem-with-visual-studio\">Report a Problem<\/a> option found in your favorite IDE under <code>Help &gt; Report a Problem<\/code>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>NuGet 6.0 &#8211; Source Mapping, Package Vulnerabilities, Faster Solution Load, Oh My! NuGet 6.0 is included in Visual Studio 2022 and .NET 6.0 out of the box. You can also download NuGet 6.0 for Windows, macOS, and Linux as a standalone executable. NuGet 6.0 is one of many releases in our .NET unification journey. Our [&hellip;]<\/p>\n","protected":false},"author":551,"featured_media":1801,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[7933,7874,7930,646],"tags":[30,7947,104,7964,7954,123,147],"class_list":["post-2159","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-feature-announcement","category-nuget","category-release-announcement","category-visual-studio","tag-announcement","tag-microsoft","tag-nuget","tag-nuget-6-0","tag-secure-supply-chain","tag-security","tag-visual-studio"],"acf":[],"blog_post_summary":"<p>NuGet 6.0 &#8211; Source Mapping, Package Vulnerabilities, Faster Solution Load, Oh My! NuGet 6.0 is included in Visual Studio 2022 and .NET 6.0 out of the box. You can also download NuGet 6.0 for Windows, macOS, and Linux as a standalone executable. NuGet 6.0 is one of many releases in our .NET unification journey. Our [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts\/2159","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\/551"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/comments?post=2159"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts\/2159\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/media\/1801"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/media?parent=2159"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/categories?post=2159"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/tags?post=2159"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}