dotnet / dotnet/project-system

NuGet restore may happen multiple times for multi-target projects

Open
#7,288 11 comments 0 reactions 1 assignee Assigned to @drewnoakes View on GitHub
Feature-NuGet Performance-Scenario-References Performance-Scenario-Solution-Open Tenet-Performance Triage-Investigate
Dominant language
C#
Stars
1k
Forks
415
PR merge metrics
No merged PRs in 30d

Description

Repro:
1, Open Roslyn solution, after everything settled, close VS.

2, Restart VS, open Roslyn solution again, notice it reaches intellisense ready state quickly after the solution explorer shows the tree

3, close the solution (keep VS open)

4, reopen Roslyn solution in the same VS session
Notice: it takes much longer times (minutes) to reach intellinsense ready state. Check asset files in the obj folder. In about 40 projects, they were modified. It doesn't happen when the solution is opened in a fresh booted VS. The content of those files are not changed.

The reason it happens is that for multiple target projects, NuGet restore happens for one of the target framework once. That removes all references for other target frameworks in those projects (and projects in their dependency closure). The rest target frameworks will be added later, and projects will eventually return to the correct state. But that leads a big perf hit, including extra number of design time builds. Also, if projects are not changed within the session, it will eliminate possibility of optimizations like skipping updating build cache, and break incremental build as well.

+ @drewnoakes

+ @panopticoncentral

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.