Skip to content

Commit 37c10e6

Browse files
authored
Disable static graph restore for file-based apps (#50245)
1 parent a1a9a3e commit 37c10e6

16 files changed

+153
-29
lines changed

src/Cli/dotnet/Commands/CliCommandStrings.resx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1601,7 +1601,11 @@ Tool '{1}' (version '{2}') was successfully installed. Entry is added to the man
16011601
</data>
16021602
<data name="PropertyDirectiveMissingParts" xml:space="preserve">
16031603
<value>The property directive needs to have two parts separated by '=' like '#:property PropertyName=PropertyValue': {0}</value>
1604-
<comment>{0} is the file path and line number.</comment>
1604+
<comment>{0} is the file path and line number.{Locked="#:property"}</comment>
1605+
</data>
1606+
<data name="StaticGraphRestoreNotSupported" xml:space="preserve">
1607+
<value>Static graph restore is not supported for file-based apps. Remove the '#:property' at {0}.</value>
1608+
<comment>{0} is the file path and line number.{Locked="#:property"}</comment>
16051609
</data>
16061610
<data name="InvalidDirectiveName" xml:space="preserve">
16071611
<value>The directive at '{2}' should contain a name without special characters and an optional value separated by '{1}' like '#:{0} Name{1}Value'.</value>
@@ -2640,4 +2644,4 @@ Proceed?</value>
26402644
<data name="PackCmdVersion" xml:space="preserve">
26412645
<value>VERSION</value>
26422646
</data>
2643-
</root>
2647+
</root>

src/Cli/dotnet/Commands/Run/VirtualProjectBuildingCommand.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -942,6 +942,7 @@ public static void WriteProjectFile(
942942
writer.WriteLine("""
943943
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
944944
<DisableDefaultItemsInProjectFolder>true</DisableDefaultItemsInProjectFolder>
945+
<RestoreUseStaticGraphEvaluation>false</RestoreUseStaticGraphEvaluation>
945946
""");
946947
}
947948

@@ -1479,7 +1480,7 @@ public sealed class Property(in ParseInfo info) : Named(info)
14791480

14801481
if (propertyValue is null)
14811482
{
1482-
return context.Diagnostics.AddError<Property?>(context.SourceFile, context.Info.Span, location => string.Format(CliCommandStrings.PropertyDirectiveMissingParts, location));
1483+
return context.Diagnostics.AddError<Property?>(context.SourceFile, context.Info.Span, static location => string.Format(CliCommandStrings.PropertyDirectiveMissingParts, location));
14831484
}
14841485

14851486
try
@@ -1491,6 +1492,12 @@ public sealed class Property(in ParseInfo info) : Named(info)
14911492
return context.Diagnostics.AddError<Property?>(context.SourceFile, context.Info.Span, location => string.Format(CliCommandStrings.PropertyDirectiveInvalidName, location, ex.Message), ex);
14921493
}
14931494

1495+
if (propertyName.Equals("RestoreUseStaticGraphEvaluation", StringComparison.OrdinalIgnoreCase) &&
1496+
MSBuildUtilities.ConvertStringToBool(propertyValue))
1497+
{
1498+
context.Diagnostics.AddError(context.SourceFile, context.Info.Span, static location => string.Format(CliCommandStrings.StaticGraphRestoreNotSupported, location));
1499+
}
1500+
14941501
return new Property(context.Info)
14951502
{
14961503
Name = propertyName,

src/Cli/dotnet/Commands/xlf/CliCommandStrings.cs.xlf

Lines changed: 7 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Cli/dotnet/Commands/xlf/CliCommandStrings.de.xlf

Lines changed: 7 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Cli/dotnet/Commands/xlf/CliCommandStrings.es.xlf

Lines changed: 7 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Cli/dotnet/Commands/xlf/CliCommandStrings.fr.xlf

Lines changed: 7 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Cli/dotnet/Commands/xlf/CliCommandStrings.it.xlf

Lines changed: 7 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Cli/dotnet/Commands/xlf/CliCommandStrings.ja.xlf

Lines changed: 7 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Cli/dotnet/Commands/xlf/CliCommandStrings.ko.xlf

Lines changed: 7 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Cli/dotnet/Commands/xlf/CliCommandStrings.pl.xlf

Lines changed: 7 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)