{"id":303,"date":"2019-09-05T09:04:05","date_gmt":"2019-09-05T09:04:05","guid":{"rendered":"http:\/\/yer.ac\/blog\/?p=303"},"modified":"2019-10-15T13:54:18","modified_gmt":"2019-10-15T13:54:18","slug":"dotnet-pack-project-reference-and-nuget-dependency","status":"publish","type":"post","link":"https:\/\/yer.ac\/blog\/2019\/09\/05\/dotnet-pack-project-reference-and-nuget-dependency\/","title":{"rendered":"Include both Nuget Package References and project reference DLL using &#8220;dotnet pack&#8221; \ud83d\udce6"},"content":{"rendered":"\n<p style=\"text-align:center\"><em>Do feel free to provide any comments\/feedback to <\/em><a href=\"https:\/\/twitter.com\/therichcarey\"><em>@TheRichCarey<\/em><\/a><em> on Twitter<\/em><\/p>\n\n\n\n<p>Recently I have been trying to generate more Nuget packages for our dotnet core projects, utilizing the <code>dotnet pack<\/code> command. One issue I have been encountering is that the command was either referencing the required nuget packages, or the project reference DLLs, never both.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The current problem.<\/h2>\n\n\n\n<p>If you have Project A which has a project reference to Project B as well as including a nuget package called Package A you would expect the generated package to contain a link to both the required nuget package, and the DLL(s) for Project B, yes?  This however is not how the dotnet pack command works. <\/p>\n\n\n\n<p>This issue is widely reported on their repo (I.e.  <a href=\"https:\/\/github.com\/NuGet\/Home\/issues\/3891\">https:\/\/github.com\/NuGet\/Home\/issues\/3891<\/a> ) and unfortunately it seems the developers and the community are in a bit of a disagreement to what is &#8220;correct&#8221;. The official stance (as I understood it) is that the project references won&#8217;t be included as they should be their own packages.  This however is not always practical or desired.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The workaround.<\/h2>\n\n\n\n<p>Plenty of workarounds have been suggested around Stack Overflow and Github including having a seperate nuspec file, using Powershell to inject things into the generated nupkg and so on&#8230;<\/p>\n\n\n\n<p>The solution below worked for me, but of course, YMMV.<\/p>\n\n\n\n<p>In the end I ditched having my own <code>.nuspec<\/code> file within my project (as per some SO posts) and instead used the CSPROJ (as recommended). Below you can see the required fields for the packaging (version, naming, etc), a reference to a nuget package, and a reference to another project within the solution. <\/p>\n\n\n\n<figure class=\"wp-block-image\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"567\" height=\"381\" data-attachment-id=\"306\" data-permalink=\"https:\/\/yer.ac\/blog\/2019\/09\/05\/dotnet-pack-project-reference-and-nuget-dependency\/image-1-3\/\" data-orig-file=\"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/09\/image-1.png?fit=567%2C381&amp;ssl=1\" data-orig-size=\"567,381\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image-1\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/09\/image-1.png?fit=300%2C202&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/09\/image-1.png?fit=567%2C381&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/09\/image-1.png?resize=567%2C381\" alt=\"CSProj Snippet of dotnet core project\" class=\"wp-image-306\" srcset=\"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/09\/image-1.png?w=567&amp;ssl=1 567w, https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/09\/image-1.png?resize=300%2C202&amp;ssl=1 300w\" sizes=\"auto, (max-width: 567px) 100vw, 567px\" \/><figcaption>Snippet of CSPROJ with basic package info filled in.<\/figcaption><\/figure>\n\n\n\n<p>If you run dotnet pack now,  it will generate an appropriately named package which will contain a nuget dependancy on <code>SomeNugetPackage<\/code>. This can be confirmed by opening the nupkg with an archive tool (7Zip,WinRar, WinZip&#8230;) and seeing that the only DLL in the <code>lib<\/code> folder will be the DLL of the project being packed.<\/p>\n\n\n\n<p>The fix is as follows:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Alter the project reference to set the <code>ReferenceOutputAssembly<\/code> flag to true, and <code>IncludeAssets<\/code> to the DLL name<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;ProjectReference Include=\"..\\ProjectB.csproj\">\n  &lt;ReferenceOutputAssembly>true&lt;\/ReferenceOutputAssembly>\n  &lt;IncludeAssets>ProjectB.dll&lt;\/IncludeAssets>\n&lt;\/ProjectReference>  <\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li>Add the following line into the <code>&lt;PropertyGroup&gt;<\/code> element<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);CopyProjectReferencesToPackage&lt;\/TargetsForTfmSpecificBuildOutput><\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li>Add new target between <code>&lt;project&gt;<\/code> tags<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;Target DependsOnTargets=\"ResolveReferences\" Name=\"CopyProjectReferencesToPackage\">\n    &lt;ItemGroup>\n      &lt;BuildOutputInPackage Include=\"@(ReferenceCopyLocalPaths->WithMetadataValue('ReferenceSourceTarget', 'ProjectReference'))\"\/>\n    &lt;\/ItemGroup>\n  &lt;\/Target><\/code><\/pre>\n\n\n\n<p>So now you end up with something that looks like this<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1222\" height=\"521\" data-attachment-id=\"307\" data-permalink=\"https:\/\/yer.ac\/blog\/2019\/09\/05\/dotnet-pack-project-reference-and-nuget-dependency\/image-2-4\/\" data-orig-file=\"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/09\/image-2.png?fit=1222%2C521&amp;ssl=1\" data-orig-size=\"1222,521\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image-2\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/09\/image-2.png?fit=300%2C128&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/09\/image-2.png?fit=700%2C298&amp;ssl=1\" src=\"https:\/\/i1.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/09\/image-2.png?fit=700%2C298\" alt=\"<Project Sdk=&quot;Microsoft.NET.Sdk&quot;&gt;\n  <PropertyGroup&gt;\n    <TargetFramework&gt;netstandard2.0<\/TargetFramework&gt;\n    <Version&gt;1.0.9<\/Version&gt;\n    <Product&gt;MyProduct<\/Product&gt;\n    <id&gt;MyProduct<\/id&gt;\n    <PackageId&gt;MyProduct<\/PackageId&gt;\n    <Authors&gt;Your name<\/Authors&gt;\n    <Company&gt;Company Name<\/Company&gt;\n    <Description&gt;My library<\/Description&gt;\n    <Copyright&gt;Copyright \u00a9 2019 MyCompany<\/Copyright&gt;\n    <TargetsForTfmSpecificBuildOutput&gt;$(TargetsForTfmSpecificBuildOutput);CopyProjectReferencesToPackage<\/TargetsForTfmSpecificBuildOutput&gt;\n  <\/PropertyGroup&gt;\n  <ItemGroup&gt;\n    <PackageReference Include=&quot;SomeNugetPackage&quot; Version=&quot;1.2.3&quot;\/&gt;  \n  <\/ItemGroup&gt;\n  <ItemGroup&gt;\n    <ProjectReference Include=&quot;..\\ProjectB.csproj&quot;&gt;\n      <ReferenceOutputAssembly&gt;true<\/ReferenceOutputAssembly&gt;\n      <IncludeAssets&gt;ProjectB.dll<\/IncludeAssets&gt;\n    <\/ProjectReference&gt;  \n  <\/ItemGroup&gt;\n  <!--Next line is to ensure that dependant DLLS are copied--&gt;\n  <Target DependsOnTargets=&quot;ResolveReferences&quot; Name=&quot;CopyProjectReferencesToPackage&quot;&gt;\n    <ItemGroup&gt;\n      <BuildOutputInPackage Include=&quot;@(ReferenceCopyLocalPaths-&gt;WithMetadataValue('ReferenceSourceTarget', 'ProjectReference'))&quot;\/&gt;\n    <\/ItemGroup&gt;\n  <\/Target&gt;\n<\/Project&gt;\n\" class=\"wp-image-307\" srcset=\"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/09\/image-2.png?w=1222&amp;ssl=1 1222w, https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/09\/image-2.png?resize=300%2C128&amp;ssl=1 300w, https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/09\/image-2.png?resize=768%2C327&amp;ssl=1 768w, https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/09\/image-2.png?resize=700%2C298&amp;ssl=1 700w, https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/09\/image-2.png?resize=1200%2C512&amp;ssl=1 1200w\" sizes=\"auto, (max-width: 1000px) 100vw, 1000px\" \/><figcaption>End result CSPROJ. (Click to enlarge)<\/figcaption><\/figure>\n\n\n\n<p>Now if you run dotnet pack you should see any project reference DLL under the <code>lib<\/code> folder of the package, and if you inspect the nuspec file inside the package (or upload it to your package repo) you should see the nuget dependencies.<\/p>\n\n\n\n<p>Hopefully this helps someone, as there is a lot of conflicting info around. Please let me know if this would cause any issues!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Recently I have been trying to generate more Nuget packages for our dotnet core projects, utilizing the dotnet pack command. One issue I have been encountering is that the command was either referencing the required nuget packages, or the project reference DLLs, never both. The current problem. If you have Project A which has a &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":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_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[6],"tags":[29,18],"class_list":["post-303","post","type-post","status-publish","format-standard","hentry","category-development","tag-nuget","tag-visualstudio"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Include both Nuget Package References and project reference DLL using &quot;dotnet pack&quot; \ud83d\udce6 - yer.ac | Adventures of a developer, and other things.<\/title>\n<meta name=\"description\" content=\"using dotnet pack to geneate a nuget package with project reference DLL *and* nuget dependancies.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/yer.ac\/blog\/2019\/09\/05\/dotnet-pack-project-reference-and-nuget-dependency\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Include both Nuget Package References and project reference DLL using &quot;dotnet pack&quot; \ud83d\udce6 - yer.ac | Adventures of a developer, and other things.\" \/>\n<meta property=\"og:description\" content=\"using dotnet pack to geneate a nuget package with project reference DLL *and* nuget dependancies.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/yer.ac\/blog\/2019\/09\/05\/dotnet-pack-project-reference-and-nuget-dependency\/\" \/>\n<meta property=\"og:site_name\" content=\"yer.ac | Adventures of a developer, and other things.\" \/>\n<meta property=\"article:published_time\" content=\"2019-09-05T09:04:05+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-10-15T13:54:18+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/yer.ac\/blog\/wp-content\/uploads\/2019\/09\/image-1.png\" \/>\n<meta name=\"author\" content=\"yer.ac\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"yer.ac\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/yer.ac\\\/blog\\\/2019\\\/09\\\/05\\\/dotnet-pack-project-reference-and-nuget-dependency\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/yer.ac\\\/blog\\\/2019\\\/09\\\/05\\\/dotnet-pack-project-reference-and-nuget-dependency\\\/\"},\"author\":{\"name\":\"yer.ac\",\"@id\":\"https:\\\/\\\/yer.ac\\\/blog\\\/#\\\/schema\\\/person\\\/4638b9d868c7d3747bd3bb01fbc8153d\"},\"headline\":\"Include both Nuget Package References and project reference DLL using &#8220;dotnet pack&#8221; \ud83d\udce6\",\"datePublished\":\"2019-09-05T09:04:05+00:00\",\"dateModified\":\"2019-10-15T13:54:18+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/yer.ac\\\/blog\\\/2019\\\/09\\\/05\\\/dotnet-pack-project-reference-and-nuget-dependency\\\/\"},\"wordCount\":379,\"commentCount\":15,\"publisher\":{\"@id\":\"https:\\\/\\\/yer.ac\\\/blog\\\/#\\\/schema\\\/person\\\/4638b9d868c7d3747bd3bb01fbc8153d\"},\"image\":{\"@id\":\"https:\\\/\\\/yer.ac\\\/blog\\\/2019\\\/09\\\/05\\\/dotnet-pack-project-reference-and-nuget-dependency\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/yer.ac\\\/blog\\\/wp-content\\\/uploads\\\/2019\\\/09\\\/image-1.png\",\"keywords\":[\"Nuget\",\"VisualStudio\"],\"articleSection\":[\"Development\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/yer.ac\\\/blog\\\/2019\\\/09\\\/05\\\/dotnet-pack-project-reference-and-nuget-dependency\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/yer.ac\\\/blog\\\/2019\\\/09\\\/05\\\/dotnet-pack-project-reference-and-nuget-dependency\\\/\",\"url\":\"https:\\\/\\\/yer.ac\\\/blog\\\/2019\\\/09\\\/05\\\/dotnet-pack-project-reference-and-nuget-dependency\\\/\",\"name\":\"Include both Nuget Package References and project reference DLL using \\\"dotnet pack\\\" \ud83d\udce6 - yer.ac | Adventures of a developer, and other things.\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/yer.ac\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/yer.ac\\\/blog\\\/2019\\\/09\\\/05\\\/dotnet-pack-project-reference-and-nuget-dependency\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/yer.ac\\\/blog\\\/2019\\\/09\\\/05\\\/dotnet-pack-project-reference-and-nuget-dependency\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/yer.ac\\\/blog\\\/wp-content\\\/uploads\\\/2019\\\/09\\\/image-1.png\",\"datePublished\":\"2019-09-05T09:04:05+00:00\",\"dateModified\":\"2019-10-15T13:54:18+00:00\",\"description\":\"using dotnet pack to geneate a nuget package with project reference DLL *and* nuget dependancies.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/yer.ac\\\/blog\\\/2019\\\/09\\\/05\\\/dotnet-pack-project-reference-and-nuget-dependency\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/yer.ac\\\/blog\\\/2019\\\/09\\\/05\\\/dotnet-pack-project-reference-and-nuget-dependency\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/yer.ac\\\/blog\\\/2019\\\/09\\\/05\\\/dotnet-pack-project-reference-and-nuget-dependency\\\/#primaryimage\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/yer.ac\\\/blog\\\/wp-content\\\/uploads\\\/2019\\\/09\\\/image-1.png?fit=567%2C381&ssl=1\",\"contentUrl\":\"https:\\\/\\\/i0.wp.com\\\/yer.ac\\\/blog\\\/wp-content\\\/uploads\\\/2019\\\/09\\\/image-1.png?fit=567%2C381&ssl=1\",\"width\":567,\"height\":381},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/yer.ac\\\/blog\\\/2019\\\/09\\\/05\\\/dotnet-pack-project-reference-and-nuget-dependency\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/yer.ac\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Include both Nuget Package References and project reference DLL using &#8220;dotnet pack&#8221; \ud83d\udce6\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/yer.ac\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/yer.ac\\\/blog\\\/\",\"name\":\"yer.ac | Adventures of a developer, and other things.\",\"description\":\"Blog to keep track of things I am upto\",\"publisher\":{\"@id\":\"https:\\\/\\\/yer.ac\\\/blog\\\/#\\\/schema\\\/person\\\/4638b9d868c7d3747bd3bb01fbc8153d\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/yer.ac\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/yer.ac\\\/blog\\\/#\\\/schema\\\/person\\\/4638b9d868c7d3747bd3bb01fbc8153d\",\"name\":\"yer.ac\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/67ed010c9cc7986d40647e061c6dcdb06d818776591c7e954055adb629621113?s=96&d=retro&r=pg\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/67ed010c9cc7986d40647e061c6dcdb06d818776591c7e954055adb629621113?s=96&d=retro&r=pg\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/67ed010c9cc7986d40647e061c6dcdb06d818776591c7e954055adb629621113?s=96&d=retro&r=pg\",\"caption\":\"yer.ac\"},\"logo\":{\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/67ed010c9cc7986d40647e061c6dcdb06d818776591c7e954055adb629621113?s=96&d=retro&r=pg\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Include both Nuget Package References and project reference DLL using \"dotnet pack\" \ud83d\udce6 - yer.ac | Adventures of a developer, and other things.","description":"using dotnet pack to geneate a nuget package with project reference DLL *and* nuget dependancies.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/yer.ac\/blog\/2019\/09\/05\/dotnet-pack-project-reference-and-nuget-dependency\/","og_locale":"en_US","og_type":"article","og_title":"Include both Nuget Package References and project reference DLL using \"dotnet pack\" \ud83d\udce6 - yer.ac | Adventures of a developer, and other things.","og_description":"using dotnet pack to geneate a nuget package with project reference DLL *and* nuget dependancies.","og_url":"https:\/\/yer.ac\/blog\/2019\/09\/05\/dotnet-pack-project-reference-and-nuget-dependency\/","og_site_name":"yer.ac | Adventures of a developer, and other things.","article_published_time":"2019-09-05T09:04:05+00:00","article_modified_time":"2019-10-15T13:54:18+00:00","og_image":[{"url":"http:\/\/yer.ac\/blog\/wp-content\/uploads\/2019\/09\/image-1.png","type":"","width":"","height":""}],"author":"yer.ac","twitter_card":"summary_large_image","twitter_misc":{"Written by":"yer.ac","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/yer.ac\/blog\/2019\/09\/05\/dotnet-pack-project-reference-and-nuget-dependency\/#article","isPartOf":{"@id":"https:\/\/yer.ac\/blog\/2019\/09\/05\/dotnet-pack-project-reference-and-nuget-dependency\/"},"author":{"name":"yer.ac","@id":"https:\/\/yer.ac\/blog\/#\/schema\/person\/4638b9d868c7d3747bd3bb01fbc8153d"},"headline":"Include both Nuget Package References and project reference DLL using &#8220;dotnet pack&#8221; \ud83d\udce6","datePublished":"2019-09-05T09:04:05+00:00","dateModified":"2019-10-15T13:54:18+00:00","mainEntityOfPage":{"@id":"https:\/\/yer.ac\/blog\/2019\/09\/05\/dotnet-pack-project-reference-and-nuget-dependency\/"},"wordCount":379,"commentCount":15,"publisher":{"@id":"https:\/\/yer.ac\/blog\/#\/schema\/person\/4638b9d868c7d3747bd3bb01fbc8153d"},"image":{"@id":"https:\/\/yer.ac\/blog\/2019\/09\/05\/dotnet-pack-project-reference-and-nuget-dependency\/#primaryimage"},"thumbnailUrl":"http:\/\/yer.ac\/blog\/wp-content\/uploads\/2019\/09\/image-1.png","keywords":["Nuget","VisualStudio"],"articleSection":["Development"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/yer.ac\/blog\/2019\/09\/05\/dotnet-pack-project-reference-and-nuget-dependency\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/yer.ac\/blog\/2019\/09\/05\/dotnet-pack-project-reference-and-nuget-dependency\/","url":"https:\/\/yer.ac\/blog\/2019\/09\/05\/dotnet-pack-project-reference-and-nuget-dependency\/","name":"Include both Nuget Package References and project reference DLL using \"dotnet pack\" \ud83d\udce6 - yer.ac | Adventures of a developer, and other things.","isPartOf":{"@id":"https:\/\/yer.ac\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/yer.ac\/blog\/2019\/09\/05\/dotnet-pack-project-reference-and-nuget-dependency\/#primaryimage"},"image":{"@id":"https:\/\/yer.ac\/blog\/2019\/09\/05\/dotnet-pack-project-reference-and-nuget-dependency\/#primaryimage"},"thumbnailUrl":"http:\/\/yer.ac\/blog\/wp-content\/uploads\/2019\/09\/image-1.png","datePublished":"2019-09-05T09:04:05+00:00","dateModified":"2019-10-15T13:54:18+00:00","description":"using dotnet pack to geneate a nuget package with project reference DLL *and* nuget dependancies.","breadcrumb":{"@id":"https:\/\/yer.ac\/blog\/2019\/09\/05\/dotnet-pack-project-reference-and-nuget-dependency\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/yer.ac\/blog\/2019\/09\/05\/dotnet-pack-project-reference-and-nuget-dependency\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/yer.ac\/blog\/2019\/09\/05\/dotnet-pack-project-reference-and-nuget-dependency\/#primaryimage","url":"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/09\/image-1.png?fit=567%2C381&ssl=1","contentUrl":"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/09\/image-1.png?fit=567%2C381&ssl=1","width":567,"height":381},{"@type":"BreadcrumbList","@id":"https:\/\/yer.ac\/blog\/2019\/09\/05\/dotnet-pack-project-reference-and-nuget-dependency\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/yer.ac\/blog\/"},{"@type":"ListItem","position":2,"name":"Include both Nuget Package References and project reference DLL using &#8220;dotnet pack&#8221; \ud83d\udce6"}]},{"@type":"WebSite","@id":"https:\/\/yer.ac\/blog\/#website","url":"https:\/\/yer.ac\/blog\/","name":"yer.ac | Adventures of a developer, and other things.","description":"Blog to keep track of things I am upto","publisher":{"@id":"https:\/\/yer.ac\/blog\/#\/schema\/person\/4638b9d868c7d3747bd3bb01fbc8153d"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/yer.ac\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/yer.ac\/blog\/#\/schema\/person\/4638b9d868c7d3747bd3bb01fbc8153d","name":"yer.ac","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/67ed010c9cc7986d40647e061c6dcdb06d818776591c7e954055adb629621113?s=96&d=retro&r=pg","url":"https:\/\/secure.gravatar.com\/avatar\/67ed010c9cc7986d40647e061c6dcdb06d818776591c7e954055adb629621113?s=96&d=retro&r=pg","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/67ed010c9cc7986d40647e061c6dcdb06d818776591c7e954055adb629621113?s=96&d=retro&r=pg","caption":"yer.ac"},"logo":{"@id":"https:\/\/secure.gravatar.com\/avatar\/67ed010c9cc7986d40647e061c6dcdb06d818776591c7e954055adb629621113?s=96&d=retro&r=pg"}}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/paP5IW-4T","jetpack-related-posts":[{"id":337,"url":"https:\/\/yer.ac\/blog\/2019\/11\/20\/identifying-nuget-package-references-which-are-using-relative-paths-across-whole-solution\/","url_meta":{"origin":303,"position":0},"title":"Identifying Nuget package references which are using relative paths across whole solution","author":"yer.ac","date":"November 20, 2019","format":false,"excerpt":"Keeping up with a recent binge upgrading projects, including upgrading all my projects in a solution to 4.8, I have been upgrading nuget packages. Whilst this is a relatively simple task, what irks me is that when you add or upgrade a nuget package in Visual Studio, it will often\u2026","rel":"","context":"In &quot;Development&quot;","block_context":{"text":"Development","link":"https:\/\/yer.ac\/blog\/category\/development\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/11\/image-2.png?fit=376%2C382&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":521,"url":"https:\/\/yer.ac\/blog\/2021\/10\/06\/vs2019-2022-keeps-asking-for-azure-devops-credentials-on-build\/","url_meta":{"origin":303,"position":1},"title":"VS2019 (+2022) keeps asking for Azure Devops Credentials on build","author":"yer.ac","date":"October 6, 2021","format":false,"excerpt":"We run our own nuget feed via Azure, and despite the user that's logged into VS is authenticated users are constantly asked to provide their credentials again when package restore is happening. A quick fix below - Mostly so I don't forget or can forward this to others later. Verify\u2026","rel":"","context":"In &quot;Azure&quot;","block_context":{"text":"Azure","link":"https:\/\/yer.ac\/blog\/category\/development\/azure\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2021\/10\/image-1.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2021\/10\/image-1.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2021\/10\/image-1.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2021\/10\/image-1.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":514,"url":"https:\/\/yer.ac\/blog\/2021\/10\/06\/fixing-hostfxr-dll-could-not-be-found-within-windows-docker-container-net-installed-from-dotnet-install-ps1\/","url_meta":{"origin":303,"position":2},"title":"Fixing &#8220;hostfxr.dll could not be found&#8221; within Windows Docker container (.NET installed from dotnet-install.ps1)","author":"yer.ac","date":"October 6, 2021","format":false,"excerpt":"This is here mostly for my own reference for next time I need to fix this, but may be useful to someone else. Installing .NET (5, Core, etc.) via the Microsoft Supplied \"dotnet-install.ps1\"(https:\/\/docs.microsoft.com\/en-us\/dotnet\/core\/tools\/dotnet-install-script) installs the frameworks fine, but then running .net core code within that windows container would sometimes yield\u2026","rel":"","context":"In &quot;Docker&quot;","block_context":{"text":"Docker","link":"https:\/\/yer.ac\/blog\/category\/devops\/docker\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2021\/10\/image.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2021\/10\/image.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2021\/10\/image.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":315,"url":"https:\/\/yer.ac\/blog\/2019\/10\/16\/ensuring-dotnet-test-trx-coverage-files-end-up-in-sonarqube\/","url_meta":{"origin":303,"position":3},"title":"Ensuring &#8220;dotnet test&#8221; TRX &#038; Coverage files end up in SonarQube","author":"yer.ac","date":"October 16, 2019","format":false,"excerpt":"I have written before about using SonarQube to do static analysis, but one issue I never came back to was ensuring that code coverage files generated via a build pipeline end up being picked up by the Sonar Scanner to assess code coverage. Note that the following I am actually\u2026","rel":"","context":"In &quot;DevOps&quot;","block_context":{"text":"DevOps","link":"https:\/\/yer.ac\/blog\/category\/devops\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/10\/image.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":527,"url":"https:\/\/yer.ac\/blog\/2023\/03\/23\/polymorphic-serialization-deserialziation-of-interface-implementations-in-net6\/","url_meta":{"origin":303,"position":4},"title":"Polymorphic Serialization &#038; Deserialziation of Interface implementations in dotnet","author":"yer.ac","date":"March 23, 2023","format":false,"excerpt":"I will preface this by saying this is not a good idea and was more of a \"I wonder..\", as you lose the benefit of a descriptive model (especially in swagger), and its somewhat brittle if you add more types. Honestly it started as a \"It would be nice if\u2026","rel":"","context":"In &quot;Development&quot;","block_context":{"text":"Development","link":"https:\/\/yer.ac\/blog\/category\/development\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":151,"url":"https:\/\/yer.ac\/blog\/2019\/05\/29\/remote-nlog-logging-with-azure-functions-part-two-persisting-data-into-azure-cosmos-db\/","url_meta":{"origin":303,"position":5},"title":"Remote NLOG logging with Azure Functions (Part two) &#8211; Persisting data into Azure Cosmos DB.","author":"yer.ac","date":"May 29, 2019","format":false,"excerpt":"Last time, I got a very basic C# Azure Function hooked up to accept a request from an NLOG web service target. This time, I will be attempting to persist(insert) the incoming log information into an Azure Cosmos database container, direct from my Azure Function in VS Code. Disclaimer: This\u2026","rel":"","context":"In &quot;Azure&quot;","block_context":{"text":"Azure","link":"https:\/\/yer.ac\/blog\/category\/development\/azure\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/05\/image-12.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/05\/image-12.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/05\/image-12.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/05\/image-12.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/05\/image-12.png?resize=1050%2C600&ssl=1 3x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/yer.ac\/blog\/wp-json\/wp\/v2\/posts\/303","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/yer.ac\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/yer.ac\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/yer.ac\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/yer.ac\/blog\/wp-json\/wp\/v2\/comments?post=303"}],"version-history":[{"count":7,"href":"https:\/\/yer.ac\/blog\/wp-json\/wp\/v2\/posts\/303\/revisions"}],"predecessor-version":[{"id":320,"href":"https:\/\/yer.ac\/blog\/wp-json\/wp\/v2\/posts\/303\/revisions\/320"}],"wp:attachment":[{"href":"https:\/\/yer.ac\/blog\/wp-json\/wp\/v2\/media?parent=303"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yer.ac\/blog\/wp-json\/wp\/v2\/categories?post=303"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yer.ac\/blog\/wp-json\/wp\/v2\/tags?post=303"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}