I have 2 Projects:
Project A is .Net Standard 2.0
Project B is .Net Framework 4.6.1
In B I reference to A like this (csproj):
<ItemGroup>
<ProjectReference Include="A.csproj">
<Project>{60DEB41B-8670-4199-95C2-FE68EB06B099}</Project>
<Name>A</Name>
</ProjectReference>
Now when I pack a nuget of B, I can't access A because it doesnt resolve the dependency.
here are the commands, run by gitlab ci, to create the project B:
nuget restore
msbuild B.csproj
nuget pack -version $VERSION
dotnet nuget push **/*.nupkg ...
How to include the lib of A as DLL in B?
Actually, adding a reference at the project level does not automatically add the corresponding reference dll during the packaging process. You need to add an additional dll
to the nuget package manually.
I have two solutions:
Solution One
Just as Cem.S
said, use -IncludeReferencedProjects
to pack your project.
Also, since you pack a net framework nuget project, you only have to use nuget.exe cli to pack the project with the created nuspec file:
Use this command to pack your project B:
nuget pack xxx\B.csproj -IncludeReferencedProjects
Solution two
Or just add such node in B.nuspec
file:
<?xml version="1.0" encoding="utf-8"?>
<package >
<metadata>
<id>xxx</id>
<version>1.0.0</version>
<title>xxx</title>
<authors>xxx</authors>
.....
</metadata>
<files>
<file src="xxx\xxx\A.dll" target="lib\net461" />
<files>
</package>
Then, run nuget pack xxx\B.csproj
to generate the new version.
Before you install the new version, you should first clean nuget caches first.