Skip to content

Disable static graph restore for file-based apps #50245

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

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