NuGet/Home

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

Open

#11.530 aberto em 28 de jan. de 2022

Ver no GitHub
 (9 comments) (0 reactions) (0 assignees)HTML (292 forks)batch import
Functionality:PackPriority:3Product:dotnet.exeType:Bughelp wanted

Métricas do repositório

Stars
 (1.459 stars)
Métricas de merge de PR
 (Mesclagem média 464d 23h) (1 fundiu PR em 30d)

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

Guia do colaborador