Add EnableDefaultItems=false optimization for restore operations
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=falseif user hasn't already specified it -
RestoreCommand.CreateForwarding(): Apply optimization for explicit restore commands (dotnet restore) -
RestoringCommand.GetSeparateRestoreCommand(): Apply optimization for implicit restore scenarios (dotnet buildwithout--no-restore) -
Comprehensive property parsing: Handles multiple MSBuild property syntax formats (
-property:,-p:,--property:) with case-insensitive matching
User Experience
- Transparent: Users won't notice any behavior changes except faster restores
-
Respects user preferences: If user explicitly sets
EnableDefaultItems=true/false, their value is preserved - Backward compatible: No breaking changes to existing workflows
Testing
Added comprehensive unit tests covering:
- Basic optimization behavior
- User override scenarios with various property syntax formats
- Case-insensitive property matching
- Integration with both explicit and implicit restore paths
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
- Triggering command:
/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:
- Configure Actions setup steps to set up my environment, which run before the firewall is enabled
- Add the appropriate URLs or hosts to my firewall allow list
💡 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.