{"id":8824,"date":"2023-10-13T06:29:40","date_gmt":"2023-10-13T06:29:40","guid":{"rendered":"https:\/\/www.bacancytechnology.com\/qanda\/?p=8824"},"modified":"2023-10-13T06:29:40","modified_gmt":"2023-10-13T06:29:40","slug":"dotnet-restore-vs-nuget-restore-with-teamcity","status":"publish","type":"post","link":"https:\/\/www.bacancytechnology.com\/qanda\/dot-net\/dotnet-restore-vs-nuget-restore-with-teamcity","title":{"rendered":"&#8216;dotnet restore&#8217; vs. &#8216;nuget restore&#8217; with TeamCity"},"content":{"rendered":"<h3>Introduction<\/h3>\n<p>When you working on an ASP.NET Core project in a CI\/CD environment like TeamCity, you might found issues where your project builds successfully in Visual Studio but fails under MSBuild, particularly when it can&#8217;t locate common libraries like system libraries. To address this, it&#8217;s crucial to understand and know the differences between two commonly used commands for restoring dependencies: &#8216;dotnet restore&#8217; and &#8216;nuget restore&#8217;. In this documentation, we will let you know the difference between them and how they impact your TeamCity build process.<\/p>\n<h3>Compatibility Overview<\/h3>\n<p><strong>dotnet restore<\/strong><\/p>\n<ul>\n<li>&#8216;dotnet restore&#8217; is a command provided by the .NET SDK, it is designed for .NET Core and .NET 5+ projects.<\/li>\n<li>It&#8217;s the way to restore project dependencies in .NET applications.<\/li>\n<li>Works with the &#8216;dotnet&#8217; CLI and is tightly integrated into the .NET ecosystem.<\/li>\n<\/ul>\n<p><strong>nuget restore<\/strong><\/p>\n<ul>\n<li>&#8216;nuget restore&#8217; is the traditional approach to restore NuGet package dependencies.<\/li>\n<li>It predates .NET Core and .NET 5+ and is generally used with older .NET Framework projects.<\/li>\n<li>Can also be used with newer .NET projects but is less commonly recommended.<\/li>\n<\/ul>\n<h3>What is the Process for Resolution?<\/h3>\n<p><strong>dotnet restore<\/strong><\/p>\n<ol>\n<li>When you execute &#8216;dotnet restore&#8217;, it analyzes the project file and fetches the necessary dependencies listed there.<\/li>\n<li>It also ensures compatibility with the target framework defined in the project file.<\/li>\n<li>&#8216;dotnet restore&#8217; uses NuGet under the hood to manage packages, making it a powerful and reliable choice.<\/li>\n<\/ol>\n<p><strong>nuget restore<\/strong><\/p>\n<ol>\n<li>&#8216;nuget restore&#8217; is a command that relies solely on NuGet for restoring packages.<\/li>\n<li>It looks at the &#8216;packages.config&#8217; file (for older projects) or the &#8216;PackageReference&#8217; elements (for newer projects) to determine the required packages.<\/li>\n<li>While &#8216;nuget restore&#8217; can work for newer projects, it may not be as efficient or have the same level of integration as &#8216;dotnet restore&#8217;.<\/li>\n<\/ol>\n<h3>Pros and Cons<\/h3>\n<p><strong>dotnet restore<\/strong><\/p>\n<p><strong>Pros:<\/strong><\/p>\n<ul>\n<li>Modern and officially recommended for .NET Core and .NET 5+ projects.<\/li>\n<li>Seamlessly integrates with the &#8216;dotnet&#8217; CLI and other .NET tools.<\/li>\n<li>Provides excellent compatibility and support for the latest .NET technologies.<\/li>\n<\/ul>\n<p><strong>Cons:<\/strong><\/p>\n<ul>\n<li>Not the ideal choice for older .NET Framework projects, which may require &#8216;nuget restore&#8217;.<\/li>\n<li>May require some configuration adjustments in older solutions or custom build scripts.<\/li>\n<\/ul>\n<p><strong>nuget restore<\/strong><\/p>\n<p><strong>Pros:<\/strong><\/p>\n<ul>\n<li>Well-established and widely used for older .NET Framework projects.<\/li>\n<li>Works reliably for projects that were originally developed using NuGet.<\/li>\n<li>Offers compatibility with legacy codebases.<\/li>\n<\/ul>\n<p><strong>Cons:<\/strong><\/p>\n<ul>\n<li>Less integrated with modern .NET Core and .NET 5+ projects.<\/li>\n<li>Not the recommended approach for new .NET Core or .NET 5+ projects.<\/li>\n<li>May require extra effort for compatibility with newer .NET technologies.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Introduction When you working on an ASP.NET Core project in a CI\/CD environment like TeamCity, you might found issues where your project builds successfully in Visual Studio but fails under MSBuild, particularly when it can&#8217;t locate common libraries like system libraries. To address this, it&#8217;s crucial to understand and know the differences between two commonly [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":8826,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[20],"tags":[],"class_list":["post-8824","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dot-net"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/posts\/8824"}],"collection":[{"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/comments?post=8824"}],"version-history":[{"count":1,"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/posts\/8824\/revisions"}],"predecessor-version":[{"id":8825,"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/posts\/8824\/revisions\/8825"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/media\/8826"}],"wp:attachment":[{"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/media?parent=8824"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/categories?post=8824"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/tags?post=8824"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}