Skip to content

Commit 5ac2276

Browse files
committed
FUTDC support for CopyToOutputDirectory="IfDifferent"
The `IfDifferent` value is valid in modern MSBuild: https://github.com/dotnet/msbuild/blob/863bbb87f1b5cbf792fbefb7005ff83bb8af0e4b/src/MSBuild/MSBuild/Microsoft.Build.CommonTypes.xsd#L776 Without this change, attempting to use it causes an error in the FUTDC: ``` ===================== 20-Nov-25 11:17:37 LimitedFunctionality System.AggregateException: Project system data flow 'UpToDateCheckConfiguredInputDataSource: 36760100' closed because of an exception. CopyToOutputDirectory should be Always or PreserveNewest, not IfDifferent ---> (Inner Exception #0) Microsoft.Assumes+InternalErrorException: CopyToOutputDirectory should be Always or PreserveNewest, not IfDifferent at Microsoft.Assumes.Fail(String message) at Microsoft.VisualStudio.ProjectSystem.VS.UpToDate.CopyItem.<GetCopyType>g__ParseCopyType|15_0(String value) at Microsoft.VisualStudio.ProjectSystem.VS.UpToDate.CopyItem.GetCopyType(IImmutableDictionary`2 metadata) at Microsoft.VisualStudio.ProjectSystem.VS.UpToDate.UpToDateCheckImplicitConfiguredInput.<>c.<Update>b__76_24(KeyValuePair`2 pair) at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext() at System.Linq.Buffer`1..ctor(IEnumerable`1 source) at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source) at System.Collections.Immutable.ImmutableArray.CreateRange[T](IEnumerable`1 items) at Microsoft.VisualStudio.ProjectSystem.VS.UpToDate.UpToDateCheckImplicitConfiguredInput.<>c__DisplayClass76_0.<Update>g__UpdateCopyData|9() at Microsoft.VisualStudio.ProjectSystem.VS.UpToDate.UpToDateCheckImplicitConfiguredInput.Update(IProjectSubscriptionUpdate jointRuleUpdate, IProjectSubscriptionUpdate sourceItemsUpdate, IProjectItemSchema projectItemSchema, IProjectCatalogSnapshot projectCatalogSnapshot) at Microsoft.VisualStudio.ProjectSystem.VS.UpToDate.UpToDateCheckImplicitConfiguredInputDataSource.<>c__DisplayClass12_0.<<LinkExternalInput>g__TransformAsync|0>d.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.VisualStudio.ProjectSystem.TransformBlockSlim`2.TransformBlockSlimAsync.<ProcessInputAsync>d__3.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Microsoft.VisualStudio.ProjectSystem.DataReceivingBlockSlim`1.<ProcessInputQueueAsync>d__5.MoveNext() <--- (Inner Exception #0) =================== ``` This change adds support for it. The FUTDC already treats "Always" in the same way as "IfDifferent" (which helps performance a lot), so the user wouldn't notice a difference between these two options for builds in VS, but there would be a different for command-line builds.
1 parent 1831049 commit 5ac2276

File tree

4 files changed

+9
-1
lines changed

4 files changed

+9
-1
lines changed

src/Microsoft.VisualStudio.ProjectSystem.Managed.VS/ProjectSystem/VS/Rules/CopyToOutputDirectoryItem.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
<EnumValue Name="Never" />
1717
<EnumValue Name="Always" />
1818
<EnumValue Name="PreserveNewest" />
19+
<EnumValue Name="IfDifferent" />
1920
</EnumProperty>
2021

2122
<BoolProperty Name="BuildAccelerationOnly"

src/Microsoft.VisualStudio.ProjectSystem.Managed.VS/ProjectSystem/VS/UpToDate/BuildUpToDateCheck.CopyType.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ internal sealed partial class BuildUpToDateCheck
1010
internal enum CopyType
1111
{
1212
PreserveNewest,
13+
IfDifferent,
1314
Always
1415
}
1516
}

src/Microsoft.VisualStudio.ProjectSystem.Managed.VS/ProjectSystem/VS/UpToDate/BuildUpToDateCheck.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -797,6 +797,7 @@ private bool CheckCopyToOutputDirectoryItems(Log log, UpToDateCheckImplicitConfi
797797
switch (copyType)
798798
{
799799
case CopyType.Always:
800+
case CopyType.IfDifferent:
800801
{
801802
// We have already validated the presence of these files, so we don't expect these to return
802803
// false. If one of them does, the corresponding size would be zero, so we would schedule a build.

src/Microsoft.VisualStudio.ProjectSystem.Managed.VS/ProjectSystem/VS/UpToDate/CopyItem.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,12 @@ static BuildUpToDateCheck.CopyType ParseCopyType(string value)
6969
return BuildUpToDateCheck.CopyType.PreserveNewest;
7070
}
7171

72-
throw Assumes.Fail($"CopyToOutputDirectory should be Always or PreserveNewest, not {value}");
72+
if (string.Equals(value, CopyToOutputDirectoryItem.CopyToOutputDirectoryValues.IfDifferent, StringComparisons.PropertyLiteralValues))
73+
{
74+
return BuildUpToDateCheck.CopyType.IfDifferent;
75+
}
76+
77+
throw Assumes.Fail($"CopyToOutputDirectory should be Always, PreserveNewest or IfDifferent, not {value}");
7378
}
7479
}
7580

0 commit comments

Comments
 (0)