Add EnableDefaultItems=false optimization for restore operations #49424
+247
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Improves restore performance by disabling default item globbing during restore operations, addressing significant performance issues on projects with large numbers of files.
Problem
During
dotnet restore
operations, MSBuild spends excessive time on default item globbing (Compile, EmbeddedResource, None items) which can take 45+ seconds on projects with 100k+ files. Restore operations don't actually need these items to be evaluated, making this globbing unnecessary overhead.Solution
Automatically adds
EnableDefaultItems=false
property to MSBuild arguments during restore operations while respecting user-provided values to avoid conflicts.Changes
Constants.AddRestoreOptimizations()
: New method that addsEnableDefaultItems=false
if user hasn't already specified itRestoreCommand.CreateForwarding()
: Apply optimization for explicit restore commands (dotnet restore
)RestoringCommand.GetSeparateRestoreCommand()
: Apply optimization for implicit restore scenarios (dotnet build
without--no-restore
)-property:
,-p:
,--property:
) with case-insensitive matchingUser Experience
EnableDefaultItems=true/false
, their value is preservedTesting
Added comprehensive unit tests covering:
Expected Impact
Based on the original performance analysis, this should reduce restore evaluation time from ~45 seconds to ~300ms on projects with large file counts.
Fixes #49415.
Warning
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
josvsblobprodcus372.vsblob.vsassets.io
/home/REDACTED/work/sdk/sdk/.dotnet/dotnet msbuild /m /nologo /clp:Summary /v:minimal /nr:true /warnaserror /p:TreatWarningsAsErrors=true /p:ContinuousIntegrationBuild=false /home/REDACTED/work/sdk/sdk/artifacts/toolset/restore.proj /t:__WriteToolsetLocation /clp:ErrorsOnly;NoSummary /p:__ToolsetLocationOutputFile=/home/REDACTED/work/sdk/sdk/artifacts/toolset/10.0.0-beta.25315.102.txt
(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.