Skip to content

Conversation

jjonescz
Copy link
Member

Closes #49876.

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR disables static graph restore for file-based apps to resolve issue #49876. The change prevents MSBuild from using static graph evaluation during restore operations for C# files that are run directly without a project file.

  • Adds RestoreUseStaticGraphEvaluation>false property to virtual project files generated for file-based apps
  • Includes test coverage for both implicit and explicit static graph restore scenarios

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/Cli/dotnet/Commands/Run/VirtualProjectBuildingCommand.cs Adds property to disable static graph evaluation in generated virtual project files
test/dotnet.Tests/CommandTests/Run/RunFileTests.cs Adds tests to verify static graph restore behavior and updates existing test project templates

@@ -891,6 +891,7 @@ public static void WriteProjectFile(
writer.WriteLine("""
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<DisableDefaultItemsInProjectFolder>true</DisableDefaultItemsInProjectFolder>
<RestoreUseStaticGraphEvaluation>false</RestoreUseStaticGraphEvaluation>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we try looking through the property directives and seeing if any of them are an explicit enable of static graph, and give a more reasonable error if so? Or is it too niche?

@jjonescz jjonescz requested a review from 333fred August 15, 2025 11:54
@jjonescz jjonescz merged commit 37c10e6 into dotnet:main Aug 18, 2025
27 checks passed
@jjonescz jjonescz deleted the sprint-static-graph-disable branch August 18, 2025 11:33
@jjonescz
Copy link
Member Author

/backport to release/10.0.1xx

Copy link
Contributor

Started backporting to release/10.0.1xx: https://github.com/dotnet/sdk/actions/runs/17297899577

Copy link
Contributor

@jjonescz backporting to "release/10.0.1xx" failed, the patch most likely resulted in conflicts:

$ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch

Applying: Disable static graph restore for file-based apps
Applying: Improve error
error: sha1 information is lacking or useless (src/Cli/dotnet/Commands/Run/VirtualProjectBuildingCommand.cs).
error: could not build fake ancestor
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0002 Improve error
Error: The process '/usr/bin/git' failed with exit code 128

Please backport manually!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-run-file Items related to the "dotnet run <file>" effort
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Static graph restore does not work with file-based apps
4 participants