From 08c104b43528c7feb646c5094f612556fcdb6dd7 Mon Sep 17 00:00:00 2001 From: Nirmal Guru Date: Wed, 13 Jan 2021 02:47:39 +0530 Subject: [PATCH] Don't double import WinFX targets (#2976) * Remove trailing whitespace Respect EditorConfig preferences for whitespace and newlines * Rearrange WinFX import and add comments The MSBuild items & targets that were defined after the WinFX targets import doesn't depend on anything from the WinFX targets. So, it is safe and better to declare the import after those items and targets definitions. * Don't import .NET Framework's implementation of WinFX targets When the SDK's implementation is being used. * Make the Framework WinFX targets import opt-out Currently there's no way to properly switch between NETFX's and CoreCLR's WinFX targets. This adds an opt-out, just in case, if we want to use the NETFX's WinFX targets instead. --- .../Sdk/Sdk.props | 2 +- .../Sdk/Sdk.targets | 3 +- .../Microsoft.NET.Sdk.WindowsDesktop.props | 111 ++++++++++-------- .../Microsoft.NET.Sdk.WindowsDesktop.targets | 77 ++++++------ .../Microsoft.WinFX.targets | 82 ++++--------- 5 files changed, 121 insertions(+), 154 deletions(-) diff --git a/packaging/Microsoft.NET.Sdk.WindowsDesktop/Sdk/Sdk.props b/packaging/Microsoft.NET.Sdk.WindowsDesktop/Sdk/Sdk.props index d9f409bd77b..8c33d1d597e 100644 --- a/packaging/Microsoft.NET.Sdk.WindowsDesktop/Sdk/Sdk.props +++ b/packaging/Microsoft.NET.Sdk.WindowsDesktop/Sdk/Sdk.props @@ -6,7 +6,7 @@ WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and created a backup copy. Incorrect changes to this file will make it impossible to load or build your projects from the command-line or the IDE. -Copyright (c) .NET Foundation. All rights reserved. +Copyright (c) .NET Foundation. All rights reserved. *********************************************************************************************** --> diff --git a/packaging/Microsoft.NET.Sdk.WindowsDesktop/Sdk/Sdk.targets b/packaging/Microsoft.NET.Sdk.WindowsDesktop/Sdk/Sdk.targets index c594b72551d..285d65252c9 100644 --- a/packaging/Microsoft.NET.Sdk.WindowsDesktop/Sdk/Sdk.targets +++ b/packaging/Microsoft.NET.Sdk.WindowsDesktop/Sdk/Sdk.targets @@ -6,7 +6,7 @@ WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and created a backup copy. Incorrect changes to this file will make it impossible to load or build your projects from the command-line or the IDE. -Copyright (c) .NET Foundation. All rights reserved. +Copyright (c) .NET Foundation. All rights reserved. *********************************************************************************************** --> @@ -14,4 +14,5 @@ Copyright (c) .NET Foundation. All rights reserved. + diff --git a/packaging/Microsoft.NET.Sdk.WindowsDesktop/targets/Microsoft.NET.Sdk.WindowsDesktop.props b/packaging/Microsoft.NET.Sdk.WindowsDesktop/targets/Microsoft.NET.Sdk.WindowsDesktop.props index 7db3f38b385..fd610f3ac50 100644 --- a/packaging/Microsoft.NET.Sdk.WindowsDesktop/targets/Microsoft.NET.Sdk.WindowsDesktop.props +++ b/packaging/Microsoft.NET.Sdk.WindowsDesktop/targets/Microsoft.NET.Sdk.WindowsDesktop.props @@ -1,4 +1,5 @@ + @@ -19,9 +20,9 @@ - - - <_WpfCommonNetFxReference Include="WindowsBase" /> + <_WpfCommonNetFxReference Include="WindowsBase" /> <_WpfCommonNetFxReference Include="PresentationCore" /> <_WpfCommonNetFxReference Include="PresentationFramework" /> @@ -93,39 +92,38 @@ - + <_SDKImplicitReference Include="@(_WpfCommonNetFxReference)" Condition="'$(UseWPF)' == 'true'"/> - + <_SDKImplicitReference Include="System.Windows.Forms" Condition="('$(UseWindowsForms)' == 'true') " /> - + <_SDKImplicitReference Include="WindowsFormsIntegration" Condition=" ('$(UseWindowsForms)' == 'true') And ('$(UseWPF)' == 'true') "/> - - - - - + Microsoft.NET.Sdk project (and show a suppressible build-time warning). - + + <_UnsupportedNETCoreAppTargetFramework Include=".NETCoreApp,Version=v1.0" /> @@ -140,17 +138,17 @@ <_UnsupportedNETStandardTargetFramework Include="@(SupportedNETStandardTargetFramework)" /> @@ -159,7 +157,18 @@ - + + + + + false + + diff --git a/packaging/Microsoft.NET.Sdk.WindowsDesktop/targets/Microsoft.NET.Sdk.WindowsDesktop.targets b/packaging/Microsoft.NET.Sdk.WindowsDesktop/targets/Microsoft.NET.Sdk.WindowsDesktop.targets index 644d4be4257..edadf38f4b3 100644 --- a/packaging/Microsoft.NET.Sdk.WindowsDesktop/targets/Microsoft.NET.Sdk.WindowsDesktop.targets +++ b/packaging/Microsoft.NET.Sdk.WindowsDesktop/targets/Microsoft.NET.Sdk.WindowsDesktop.targets @@ -1,28 +1,26 @@ - <_MicrosoftNetSdkWindowsDesktop>true + <_MicrosoftNETSdkWindowsDesktop>true true true Wpf - <_WindowsDesktopSdkTargetFrameworkVersionFloor>3.0 - - @@ -30,24 +28,24 @@ - <_TargetFrameworkVersionValue>$([MSBuild]::ValueOrDefault('$(_TargetFrameworkVersionWithoutV)', '$(_UndefinedTargetFrameworkVersion)')) @@ -71,33 +69,28 @@ '$(_TargetFrameworkVersionValue)' >= '$(_WindowsDesktopSdkTargetFrameworkVersionFloor)'">true - - - = '$(_WindowsDesktopSdkTargetFrameworkVersionFloor)')"> - - - - @@ -133,29 +126,33 @@ - + --> - - + --> + + + + diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Microsoft.WinFX.targets b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Microsoft.WinFX.targets index 29d21fca28f..32ba51576be 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Microsoft.WinFX.targets +++ b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Microsoft.WinFX.targets @@ -19,10 +19,9 @@ true None - + - true - false 1.0.0.0 Installed @@ -51,32 +48,26 @@ - true true true true - - - AssignWinFXEmbeddedResource; $(PrepareResourceNamesDependsOn) - - MarkupCompilePass1; AfterMarkupCompilePass1; @@ -85,23 +76,19 @@ MainResourcesGeneration; $(PrepareResourcesDependsOn) - - DesignTimeMarkupCompilation; $(CoreCompileDependsOn) - - @@ -111,12 +98,10 @@ - - @@ -147,12 +132,10 @@ - - $(CompileDependsOn); _AfterCompileWinFXInternal @@ -174,13 +157,11 @@ Target PrepareResourcesForSatelliteAssemblies is for this. --> - <_AfterCompileWinFXInternalDependsOn> PrepareResourcesForSatelliteAssemblies; MergeLocalizationDirectives; AfterCompileWinFX - @@ -237,6 +218,7 @@ <_IntellisenseOnlyCompile>false <_IntellisenseOnlyCompile Condition="'$(BuildingProject)' != 'true'">true + - @@ -277,10 +258,8 @@ - - @@ -334,7 +313,6 @@ If MarupCompilePass2 is for Main Assembly as well, output the Baml files into GeneratedBaml, FileClassifier task will be invoked later. --> - @@ -347,9 +325,7 @@ TaskParameter="GeneratedBaml" Condition="'$(_RequireMCPass2ForSatelliteAssemblyOnly)' == 'true'" /> - - @@ -375,7 +351,6 @@ --> - GenerateTemporaryTargetAssembly; MarkupCompilePass2; @@ -385,7 +360,7 @@ <_CompileTargetNameForLocalType Condition="'$(_CompileTargetNameForLocalType)' == ''">_CompileTemporaryAssembly - + false <_ResolveProjectReferencesTargetName Condition="'$(IncludePackageReferencesDuringMarkupCompilation)' != 'false'">ResolveProjectReferences <_CompileTemporaryAssemblyDependsOn>BuildOnlySettings;ResolveKeySource;$(_ResolveProjectReferencesTargetName);CoreCompile @@ -410,10 +385,10 @@ Name : GenerateTemporaryTargetAssembly --> - + - + <_ParentProjectName>$([System.IO.Path]::GetFileNameWithoutExtension('$(MSBuildProjectFullPath)')) @@ -431,22 +406,21 @@ <_DestGeneratedNuGetPropsAndTargets Include="$(MSBuildProjectExtensionsPath)$(_TemporaryTargetAssemblyProjectName).nuget.g.props"/> <_DestGeneratedNuGetPropsAndTargets Include="$(MSBuildProjectExtensionsPath)$(_TemporaryTargetAssemblyProjectName).nuget.g.targets"/> <_DestGeneratedNuGetPropsAndTargets Include="$(MSBuildProjectExtensionsPath)$(_TemporaryTargetAssemblyProjectName).nuget.dgspec.json"/> - @@ -455,18 +429,18 @@ <_IntermediateOutputPathNoTargetFrameworkOrRID>$([System.Text.RegularExpressions.Regex]::Replace($(_IntermediateOutputPathNoTargetFrameworkOrRID), "$(RuntimeIdentifier)\\$",, System.Text.RegularExpressions.RegexOptions.IgnoreCase)) - - <_IntermediateOutputPathNoTargetFrameworkOrRID>$([System.Text.RegularExpressions.Regex]::Replace($(_IntermediateOutputPathNoTargetFrameworkOrRID), "$(TargetFramework)\\$",, System.Text.RegularExpressions.RegexOptions.IgnoreCase)) - + @@ -492,10 +466,10 @@ - + - false - Internet - $(TargetUrl)/$(TargetDeployManifestFileName) $(MSBuildProjectDirectory)\bin\$(Configuration)\$(TargetDeployManifestFileName) -debug "$(StartURL)" @@ -629,13 +599,12 @@ - - @@ -716,7 +685,6 @@ --> - - - <_ResourceNameInMainAssembly Condition="'$(UICulture)' == ''">$(AssemblyName).g.resources - <_ResourceNameInMainAssembly Condition="'$(UICulture)' != ''">$(AssemblyName).unlocalizable.g.resources - - @@ -808,7 +771,6 @@ - @@ -978,7 +940,6 @@ AdditionalMetadata="CopyToOutputDirectory=PreserveNewest; TargetPath=$(AssemblyName).loc" > - @@ -1010,8 +971,7 @@ - + -