Include referenced project in nuget package
I have a solution with 3 projects (using netstandard1.4). Project A contains shared code. Project B is a server side library and project C is a client side library. Projects B and C include Project A as a project reference.
Now I want to publish Project B and Project C as a nugget package.
The problem is that the nugget packages for projects B and C do not contain the code / dll from project A. It looks like project B and C want project A to be a nuget package as well.
How can I package projects B and C as standalone nugget packages? I don't want to publish project A as a nugget package.
source to share
How can I package projects B and C as standalone nugget packages? I don't want to publish project A as a nugget package.
Since you are using netstandard1.4, you cannot use the direct " donet pack
" method to include project references. Since this dotnet pack
will only pack the project and not its P2P links, you can get the details from the dotnet-pack doc and the GitHub issue :
The NuGet dependencies of the packaged project are added to the .nuspec file, so they are resolved correctly when the package is installed. Project-project references are not packaged within the project. Currently you should have a single project package if you have dependencies between projects.
If you want packages B and C to contain the code / dlls from project A, you can use NuGet.exe to create packages B and C by adding project reference assemblies to your .nuspec file:
<?xml version="1.0"?>
<package >
<metadata>
<id>TestProjectB</id>
<version>1.0.0</version>
<authors>Tester</authors>
<owners>Tester</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Package description</description>
<releaseNotes>Test sample for netstandard package.</releaseNotes>
<copyright>Copyright 2017</copyright>
<tags>Tag1 Tag2</tags>
</metadata>
<files>
<file src="bin\Debug\netstandard1.4\TestProjectB.dll" target="lib\netstandard1.4\TestProjectB.dll" />
<file src="bin\Debug\netstandard1.4\TestProjectA.dll" target="lib\netstandard1.4\TestProjectA.dll" />
</files>
</package>
In this case, you can package projects B and C as standalone nugget packages, no need to publish project A as a nugget package.
source to share