NuGet/Home

[Bug]: Pack target is causing unnecessary project evaluations which noticeably slows down a project's build

Open

#11 530 ouverte le 28 janv. 2022

Voir sur GitHub
 (9 commentaires) (0 réactions) (0 assignés)HTML (292 forks)batch import
Functionality:PackPriority:3Product:dotnet.exeType:Bughelp wanted

Métriques du dépôt

Stars
 (1 459 stars)
Métriques de merge PR
 (Merge moyen 464j 23h) (1 PR mergée en 30 j)

Description

NuGet Product Used

dotnet.exe

Product Version

6.0.100

Worked before?

No response

Impact

It bothers me. A fix would be nice

Repro Steps & Context

When building a .NET project which sets the GeneratePackOnBuild switch or when invoking the Pack target, NuGet calls into the underlying projects via an MSBuild Exec task (i.e. based on the project.assets.json data) and set BuildProjectReferences=false as a global property. Because of the global property, additional project evaluations are triggered which slow down the overall build.

This is especially noticeable when projects multi-target. As an example, let's consider a project "A" that multi-targets for net6.0;net5.0;netstandard2.0;net48. Based on the the described issue, the evaluations double from 5 to 10:

Before:

Outer build net6.0;net5.0;netstandard2.0;net48 Inner build net6.0 Inner build net5.0 Inner build netstandard2.0 Inner build net48

After:

Outer build net6.0;net5.0;netstandard2.0;net48 Inner build net6.0 Inner build net5.0 Inner build netstandard2.0 Inner build net48 Outer build net6.0;net5.0;netstandard2.0;net48 with additional BuildProjectReferences global property Inner build net6.0 with additional BuildProjectReferences global property Inner build net5.0 with additional BuildProjectReferences global property Inner build netstandard2.0 with additional BuildProjectReferences global property Inner build net48 with additional BuildProjectReferences global property

Shouldn't it be possible to avoid these extra evaluations by sequencing the gathering of the required data into the already running outer build, which runs without the BuildProjectReferences global property?

Verbose Logs

No response

Guide contributeur