Open odalet opened 2 years ago
We're not convinced this should be changed at this time. The .NET SDK is currently in charge of dispatching builds for projects and currently it calls the "outer" build of Lib1 which dispatches two "inner" builds for Lib1, one for each target framework. Each inner build of Lib1 then dispatches an inner build to Lib2 for that specific target framework to fulfill the project reference. Once the outer build of Lib1 is complete, NuGet then calls pack on the entry project since GeneratePackageOnBuild
is set to true
. NuGet would need to then dispatch outer builds on all dependent projects so they could be packed.
However, we see dotnet build
with GeneratePackageOnBuild
to be the same as running dotnet pack
. The pack gesture in our opinion means an operation that should be run on the entry project only. I'm not convinced that packing the project in the current directory and all transitive dependencies is what people expect to happen.
This works already when you pack a Visual Studio solution file because the .NET SDK dispatches all of the outer builds since that is what a solution file is for, indicating all of the projects to build as a unit. In this case, it makes sense that pack would run for each project.
We'll leave this issue open for now so the community can comment. Please leave feedback or upvote if you feel the design should change. One way I envision this working is a new property like PackTransitive
would be added and NuGet would then dispatch Pack
target builds to all of the project references first. But this might have some side effects that cause other issues since its a behavior change.
NuGet Product(s) Affected
dotnet.exe
Current Behavior
Consider this scenario:
net48
andnet6.0
and hasGeneratePackageOnBuild
set totrue
Now, let's
dotnet build Lib1.csproj
:nupkg
nupkg
thoughDesired Behavior
Lib2.nupkg
should be generatedI understand it is probably not straightforward, but according to the least surprise principle, I think it'd be desirable.
Additional Context
Steps to Reproduce
Lib1.nupkg
is created inLib1\bin\Debug
Lib2.nupkg
is notLib2\bin\Debug
I also attached the corresponding binlog (build in release configuration this time): binlog.zip
Analysis
I've skimmed through the binlog and I think it boils down to
IsInnerBuild = true
preventing Lib2's nuget package from being generated. Here is what I guess happens:IsInnerBuild = true
mode.net48
andnet6.0
targetsLib1.nupkg
)IsInnerBuild = false
, its package is never generated.Versions & Configurations
dotnet --version
: 6.0.303