From 6110562dddf242c71a9886dc282e1f0b5c0cdb26 Mon Sep 17 00:00:00 2001 From: Cameron Beeley Date: Mon, 13 Jul 2026 12:26:12 +0100 Subject: [PATCH] Exclude _wpftmp temp project from design-time markup compilation The temporary *_wpftmp markup-compile project generated by GenerateTemporaryTargetAssembly exists only to compile the already-generated code-behind, which it lists explicitly. Under the .NET 10 SDK, CoreCompileDependsOn now runs DesignTimeMarkupCompilation for command-line design-time builds ('$(DesignTimeBuild)' == 'true'), and this also fires inside the _wpftmp project, adding the generated *.g.cs a second time and tripping NETSDK1022 (Duplicate 'Compile' items). Exclude _wpftmp projects from the design-time markup-compilation dependency so the generated files are listed exactly once. Real projects are unaffected and SDK 8 behavior is unchanged. Fixes #11775. --- .../src/PresentationBuildTasks/Microsoft.WinFX.targets | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Microsoft.WinFX.targets b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Microsoft.WinFX.targets index d3c9ba6d6eb..6fe3e3c3f7a 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Microsoft.WinFX.targets +++ b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Microsoft.WinFX.targets @@ -78,8 +78,10 @@ - + can "see" the generated source files. The temporary '*_wpftmp' project is excluded: it exists only + to compile the already-generated code (which it lists explicitly), so running markup compilation for + it too would add the generated *.g.cs a second time and trip NETSDK1022 (Duplicate 'Compile' items). --> + DesignTimeMarkupCompilation; $(CoreCompileDependsOn)