{"id":3453,"date":"2015-10-15T21:00:40","date_gmt":"2015-10-15T21:00:40","guid":{"rendered":"http:\/\/putridparrot.com\/blog\/?p=3453"},"modified":"2015-10-15T21:00:40","modified_gmt":"2015-10-15T21:00:40","slug":"how-to-reference-an-existing-nuget-package-from-a-new-project","status":"publish","type":"post","link":"https:\/\/putridparrot.com\/blog\/how-to-reference-an-existing-nuget-package-from-a-new-project\/","title":{"rendered":"How to reference an existing NuGet package from a new project"},"content":{"rendered":"<p><strong>So the scenario is this&#8230;<\/strong><\/p>\n<p>I&#8217;ve created a solution, added my projects, added some NuGet packages and all&#8217;s good with the world. Then I need to add a new project and reference some NuGet packages which I&#8217;m already using.<\/p>\n<p><strong>What&#8217;s the best way to do this?<\/strong><\/p>\n<p>In the past I&#8217;d go to the &#8220;Manage NuGet Packages&#8221; on the references section of a project and add the package again. However here&#8217;s the problem with this solution &#8211; unless you specify a specific version (you&#8217;ll be doing this through the Package Manager Console), you may find a different version of a package installed into your solution, which has its obvious downsides.<\/p>\n<p>What about referencing the assemblies you require directly, i.e. use Add Reference and browse for them? I don&#8217;t actually know (at this time) whether this causes problems for NuGet with updates etc. but it&#8217;s not a great way when a package requires multiple assemblies, which make up a package.<\/p>\n<p>What we really want is a way to say, reuse this package (already downloads and installed in the solution file system) in my new project.<\/p>\n<p><strong>The solution is simple, but I never noticed it before (how embarrassing)<\/strong><\/p>\n<p>One of the projects I&#8217;m working on has NuGet packages hosted in-house and they change often (hey its continuous deployment, that&#8217;s cool). So when I create a new project, all I want to do is get NuGet to somehow reference my existing package(s) and have NuGet handle all the references etc. <\/p>\n<p>Well it&#8217;s actually all there, built into NuGet\/Visual Studio.<\/p>\n<ul>\n<li>Select the solution in solution explorer<\/li>\n<li>Right mouse click and select Manage NuGet Packages for solution&#8230;<\/li>\n<li>Select Installed packages<\/li>\n<li>Locate the package that&#8217;s already installed<\/li>\n<li>Click the Manager button<\/li>\n<li>Now simply locate your new project and tick the checkbox next<\/li>\n<li>Click OK, sit back and relax<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>So the scenario is this&#8230; I&#8217;ve created a solution, added my projects, added some NuGet packages and all&#8217;s good with the world. Then I need to add a new project and reference some NuGet packages which I&#8217;m already using. What&#8217;s the best way to do this? In the past I&#8217;d go to the &#8220;Manage NuGet [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[66],"tags":[],"class_list":["post-3453","post","type-post","status-publish","format-standard","hentry","category-nuget"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/3453","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/comments?post=3453"}],"version-history":[{"count":4,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/3453\/revisions"}],"predecessor-version":[{"id":3464,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/3453\/revisions\/3464"}],"wp:attachment":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/media?parent=3453"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/categories?post=3453"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/tags?post=3453"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}