Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jun 16, 2025

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 adds EnableDefaultItems=false if 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 build without --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:


💡 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.

Copilot AI changed the title [WIP] SDK should disable default item globbing when asking MSBuild to perform implicit Restores Add EnableDefaultItems=false optimization for restore operations Jun 16, 2025
Copilot AI requested a review from baronfel June 16, 2025 20:51
Copilot finished work on behalf of baronfel June 16, 2025 20:51
@baronfel baronfel force-pushed the copilot/fix-49415 branch from 36eadb9 to 63e5607 Compare June 20, 2025 19:22
@baronfel
Copy link
Member

closing this as we need something more comprehensive

@baronfel baronfel closed this Jun 25, 2025
@MichaelSimons MichaelSimons deleted the copilot/fix-49415 branch September 29, 2025 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SDK should disable default item globbing when asking MSBuild to perform implicit Restores

2 participants