NuGet product used: dotnet pack
NuGet version: 4.1.0.2450
dotnet.exe --version: 1.1.0
VS version: VS2017 15.3.3
OS version: Windows 10 v1703 (15063.540)
Worked before? I don't think so
ProjectReference
to Bdotnet pack
A => creates a package A with a dependency to package B (which is nice, but I didn't see it documented anywhere)IsPackable
to False
would do this, but IsPackable
is ignored, so package A ends up with a dependency on a package B that doesn't exist.See this repo: https://github.com/thomaslevesque/TestDotnetPackBug
Or the attached project: TestPack.zip
If you just want to build A and ignore B from there. Then you can set PrivateAssets
to all which will skip generating package B.
<ProjectReference Include="../B/B.csproj">
<PrivateAssets>all</PrivateAssets>
</ProjectReference>
Thanks, but it's not really what I want... Doing that wouldn't include assembly B in package A.
@thomaslevesque you may want to use a custom msbuild target to do that as I described in https://github.com/NuGet/Home/issues/3891#issuecomment-330668337
@dasMulli interesting. I'll consider it, thanks!
But the thing is, I really think the current dotnet pack
behavior is a bug. Generating a package reference to a project that can't be packaged is clearly wrong. PrivateAssets="all"
doesn't solve the problem, because it implies that it's a development dependency, not needed at runtime, which might not be the case.
IMO, for a project A with a reference to project B, dotnet pack
should do the following:
lib
folder of package A@dasMulli thanks for referencing this to #3891 Marking this dupe of that.
@thomaslevesque please up-vote on the original issue. It's a P0 for us and we would like to take it as soon as we can for earliest release.
Relying on PrivateAssets="all"
(while works) is not a great solution here because this prevents you from returning any data types defined in those assemblies. Ideally, we would be able to just suppress the dependency generation in nuget packages on its own without resorting to manually editing it after.
Most helpful comment
@dasMulli interesting. I'll consider it, thanks!
But the thing is, I really think the current
dotnet pack
behavior is a bug. Generating a package reference to a project that can't be packaged is clearly wrong.PrivateAssets="all"
doesn't solve the problem, because it implies that it's a development dependency, not needed at runtime, which might not be the case.IMO, for a project A with a reference to project B,
dotnet pack
should do the following:lib
folder of package A