{"id":5485,"date":"2024-03-10T07:00:00","date_gmt":"2024-03-10T00:00:00","guid":{"rendered":"https:\/\/www.phanxuanchanh.com\/2024\/03\/10\/how-to-clear-nuget-cache\/"},"modified":"2024-11-24T11:26:56","modified_gmt":"2024-11-24T04:26:56","slug":"how-to-clear-nuget-cache","status":"publish","type":"post","link":"https:\/\/www.phanxuanchanh.com\/en\/2024\/03\/10\/how-to-clear-nuget-cache\/","title":{"rendered":"How to Clear NuGet Cache?"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">What is NuGet Cache? When and Why Should You Clear NuGet Cache? How to Clear NuGet Cache? These are the main topics of this article.   <\/p>\n\n<h2 class=\"wp-block-heading\">What is NuGet Cache?<\/h2>\n\n<p class=\"wp-block-paragraph\">NuGet Cache is a buffer that stores NuGet packages that have been downloaded to your computer for reuse in other projects or within the same project when needed. When you install a NuGet package, it is downloaded from the NuGet repository and stored in your cache folder. If you reinstall that package or install a different version of that package in the future, NuGet will use the package from the cache instead of downloading it again from the NuGet repository. This can help speed up the installation of NuGet packages and reduce network resources used.   <\/p>\n\n<h2 class=\"wp-block-heading\" id=\"v&#x1ECB;-tri-luu\">Location of Storage<\/h2>\n\n<p class=\"wp-block-paragraph\">The location where it stores has a path in the following format:<\/p>\n\n<ul class=\"wp-block-list\">\n<li>Windows: <code><strong>%userprofile%\\.nuget\\packages<\/strong><\/code><\/li>\n\n\n\n<li>Mac\/Linux: <code><strong>~\/.nuget\/packages<\/strong><\/code><\/li>\n<\/ul>\n\n<h2 class=\"wp-block-heading\" id=\"vi&#x1EC7;c-xoa-nuget-cache-co-tac-d&#x1EE5;ng-gi\">What is the Benefit of Clearing NuGet Cache?<\/h2>\n\n<p class=\"wp-block-paragraph\">Normally, there is no need to clear NuGet Cache. However, if you work with many projects, the number of packages downloaded and stored in the cache folder will increase over time. As a result, the cache folder (.nuget) will occupy more and more disk space. In this case, clearing NuGet Cache will help free up the space it is occupying.  <\/p>\n\n<h2 class=\"wp-block-heading\" id=\"cach-xoa-nuget-package-cache\">How to Clear NuGet Package Cache<\/h2>\n\n<p class=\"wp-block-paragraph\"><strong>Clearing via Command Line:<\/strong><\/p>\n\n<pre class=\"wp-block-code language-plaintext\"><code>dotnet nuget locals all -clear<\/code><\/pre>\n\n<p class=\"wp-block-paragraph\"><strong>Clearing in Visual Studio:<\/strong><\/p>\n\n<p class=\"wp-block-paragraph\">To clear the NuGet Package Cache in Visual Studio, go to Tools =&gt; Options =&gt; NuGet Package Manager. Then click Clear All NuGet Cache and wait for the process to complete. <\/p>\n<div class=\"wp-block-image\">\n<figure data-wp-context=\"{&quot;imageId&quot;:&quot;6a297223e5c07&quot;}\" data-wp-interactive=\"core\/image\" data-wp-key=\"6a297223e5c07\" class=\"aligncenter size-full wp-lightbox-container\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"706\" height=\"477\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on--pointerdown=\"actions.preloadImage\" data-wp-on--pointerenter=\"actions.preloadImageWithDelay\" data-wp-on--pointerleave=\"actions.cancelPreload\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/i0.wp.com\/www.phanxuanchanh.com\/wp-content\/uploads\/2024\/03\/6a483d5b266963998e06847bebe07835.png?resize=706%2C477&#038;ssl=1\" loading=\"lazy\" alt=\"Clearing NuGet Cache in Visual Studio.\" class=\"wp-image-4050\" srcset=\"https:\/\/i0.wp.com\/www.phanxuanchanh.com\/wp-content\/uploads\/2024\/03\/6a483d5b266963998e06847bebe07835.png?w=846&amp;ssl=1 846w, https:\/\/i0.wp.com\/www.phanxuanchanh.com\/wp-content\/uploads\/2024\/03\/6a483d5b266963998e06847bebe07835.png?resize=300%2C203&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.phanxuanchanh.com\/wp-content\/uploads\/2024\/03\/6a483d5b266963998e06847bebe07835.png?resize=768%2C519&amp;ssl=1 768w\" sizes=\"auto, (max-width: 706px) 100vw, 706px\" \/><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\tdata-wp-bind--aria-label=\"state.thisImage.triggerButtonAriaLabel\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.thisImage.buttonRight\"\n\t\t\tdata-wp-style--top=\"state.thisImage.buttonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewBox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><figcaption class=\"wp-element-caption\">Clearing NuGet Cache in Visual Studio.<\/figcaption><\/figure>\n<\/div>\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n<p class=\"wp-block-paragraph\">In summary, there are two ways to clear NuGet Cache: by using the command line or by clearing it in Visual Studio. Clearing NuGet Cache helps free up disk space it occupies when necessary. <\/p>\n<script type=\"text\/javascript\" src=\"https:\/\/cdnjs.buymeacoffee.com\/1.0.0\/button.prod.min.js\" data-name=\"bmc-button\" data-slug=\"phanxuanchanh\" data-color=\"#FFDD00\" data-emoji=\"\" data-font=\"Arial\" data-text=\"T\u1eb7ng t\u00f4i m\u1ed9t ly c\u00e0 ph\u00ea\" data-outline-color=\"#000000\" data-font-color=\"#000000\" data-coffee-color=\"#ffffff\" ><\/script>","protected":false},"excerpt":{"rendered":"<p>What is NuGet Cache? When and Why Should You Clear NuGet Cache? How to Clear NuGet Cache? These are the main topics of this article&#8230;.<\/p>\n","protected":false},"author":1,"featured_media":4044,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[600],"tags":[740],"quality_rating":[680],"class_list":["post-5485","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-programming","tag-nuget-package-manager-en","quality_rating-ok"],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/www.phanxuanchanh.com\/wp-content\/uploads\/2024\/03\/00ec4eeef1757910e132eb234febe4ae.png?fit=735%2C388&ssl=1","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.phanxuanchanh.com\/en\/wp-json\/wp\/v2\/posts\/5485","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.phanxuanchanh.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.phanxuanchanh.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.phanxuanchanh.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.phanxuanchanh.com\/en\/wp-json\/wp\/v2\/comments?post=5485"}],"version-history":[{"count":1,"href":"https:\/\/www.phanxuanchanh.com\/en\/wp-json\/wp\/v2\/posts\/5485\/revisions"}],"predecessor-version":[{"id":5486,"href":"https:\/\/www.phanxuanchanh.com\/en\/wp-json\/wp\/v2\/posts\/5485\/revisions\/5486"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.phanxuanchanh.com\/en\/wp-json\/wp\/v2\/media\/4044"}],"wp:attachment":[{"href":"https:\/\/www.phanxuanchanh.com\/en\/wp-json\/wp\/v2\/media?parent=5485"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.phanxuanchanh.com\/en\/wp-json\/wp\/v2\/categories?post=5485"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.phanxuanchanh.com\/en\/wp-json\/wp\/v2\/tags?post=5485"},{"taxonomy":"quality_rating","embeddable":true,"href":"https:\/\/www.phanxuanchanh.com\/en\/wp-json\/wp\/v2\/quality_rating?post=5485"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}