From f50a5c1192930e11eda27ee5f1a8481d393cc55e Mon Sep 17 00:00:00 2001 From: Arlo Date: Fri, 20 Dec 2024 14:46:10 -0600 Subject: [PATCH 1/7] Rewired and cleaned up "Available" vs "Enabled" MultiTargets and TargetFrameworks. Lifted TFM toggling above TFM declarations into MultiTarget system, enables overriding "Available" TargetFrameworks properly per-project. --- Build-Toolkit-Components.ps1 | 8 +- MultiTarget/AvailableMultiTargets.props | 18 +++++ MultiTarget/AvailableTargetFrameworks.props | 23 +++--- MultiTarget/EnabledMultiTargets.props | 13 +-- MultiTarget/EnabledTargetFrameworks.props | 45 ++++++----- MultiTarget/Library.props | 9 ++- MultiTarget/MultiTargetIdentifiers.props | 34 ++++---- .../MultiTargetToTargetFramework.props | 31 ------- MultiTarget/UseTargetFrameworks.ps1 | 80 +++---------------- .../Wasdk/CommunityToolkit.App.Wasdk.csproj | 3 + .../Wasm/CommunityToolkit.App.Wasm.csproj | 4 + ProjectHeads/App.Head.Uwp.props | 2 +- ProjectHeads/Head.WinAppSdk.props | 2 +- 13 files changed, 105 insertions(+), 167 deletions(-) create mode 100644 MultiTarget/AvailableMultiTargets.props delete mode 100644 MultiTarget/MultiTargetToTargetFramework.props diff --git a/Build-Toolkit-Components.ps1 b/Build-Toolkit-Components.ps1 index c461bddd..97dface1 100644 --- a/Build-Toolkit-Components.ps1 +++ b/Build-Toolkit-Components.ps1 @@ -95,6 +95,10 @@ Param ( [switch]$Verbose ) +# Use the specified MultiTarget TFM and WinUI version +& $PSScriptRoot\MultiTarget\UseUnoWinUI.ps1 $WinUIMajorVersion +& $PSScriptRoot\MultiTarget\UseTargetFrameworks.ps1 -MultiTargets $MultiTargets -ExcludeMultiTargets $ExcludeMultiTargets + if ($MultiTargets -eq 'all') { $MultiTargets = @('wasm', 'uwp', 'wasdk', 'wpf', 'linuxgtk', 'macos', 'ios', 'android', 'netstandard') } @@ -128,10 +132,6 @@ if ($ExcludeComponents) { $Components = $Components | Where-Object { $_ -notin $ExcludeComponents } } -# Use the specified MultiTarget TFM and WinUI version -& $PSScriptRoot\MultiTarget\UseTargetFrameworks.ps1 $MultiTargets -& $PSScriptRoot\MultiTarget\UseUnoWinUI.ps1 $WinUIMajorVersion - function Invoke-MSBuildWithBinlog { param ( [string]$TargetHeadPath diff --git a/MultiTarget/AvailableMultiTargets.props b/MultiTarget/AvailableMultiTargets.props new file mode 100644 index 00000000..efd9fe51 --- /dev/null +++ b/MultiTarget/AvailableMultiTargets.props @@ -0,0 +1,18 @@ + + + + true + + + + + + + + + + + + $(AvailableMultiTargets);$(MultiTarget) + + diff --git a/MultiTarget/AvailableTargetFrameworks.props b/MultiTarget/AvailableTargetFrameworks.props index 9d9b5869..5f548aad 100644 --- a/MultiTarget/AvailableTargetFrameworks.props +++ b/MultiTarget/AvailableTargetFrameworks.props @@ -1,22 +1,27 @@ + - uap10.0.17763; - uap10.0.17763;net8.0-windows10.0.26100.0; - net9.0-windows10.0.19041.0;net8.0-windows10.0.19041.0; + uap10.0.17763; + uap10.0.17763;net8.0-windows10.0.26100.0; + net9.0-windows10.0.19041.0;net8.0-windows10.0.19041.0; net9.0; net9.0; net9.0; - net9.0-android; - net9.0-maccatalyst; - net9.0-ios; + net9.0-android; + net9.0-maccatalyst; + net9.0-ios; - net9.0; - net9.0; - net9.0; + net9.0; + net9.0; + net9.0; netstandard2.0 diff --git a/MultiTarget/EnabledMultiTargets.props b/MultiTarget/EnabledMultiTargets.props index 3781585e..47de0231 100644 --- a/MultiTarget/EnabledMultiTargets.props +++ b/MultiTarget/EnabledMultiTargets.props @@ -1,14 +1,7 @@ - + + - true + wasm;uwp;netstandard - - - - - - - - diff --git a/MultiTarget/EnabledTargetFrameworks.props b/MultiTarget/EnabledTargetFrameworks.props index 93819344..6f1c0ab9 100644 --- a/MultiTarget/EnabledTargetFrameworks.props +++ b/MultiTarget/EnabledTargetFrameworks.props @@ -1,25 +1,26 @@ - - - - uap10.0.17763; - uap10.0.17763;net8.0-windows10.0.26100.0; - - - net9.0; - net9.0; - net9.0; - - - - + + + + $(TargetFrameworks);$(UwpTargetFrameworks) + $(TargetFrameworks);$(WinAppSdkTargetFrameworks) - - net9.0; - net9.0; - net9.0; + + true + true + $(TargetFrameworks);$(DotnetCommonTargetFramework) - - netstandard2.0 - net9.0; - + $(TargetFrameworks);$(MacOSLibTargetFrameworks) + $(TargetFrameworks);$(iOSLibTargetFrameworks) + $(TargetFrameworks);$(AndroidLibTargetFrameworks) + + $(TargetFrameworks);$(DotnetStandardCommonTargetFramework) + diff --git a/MultiTarget/Library.props b/MultiTarget/Library.props index 11158154..6aa3c1a2 100644 --- a/MultiTarget/Library.props +++ b/MultiTarget/Library.props @@ -5,13 +5,14 @@ false - + + + + - - - + diff --git a/MultiTarget/MultiTargetIdentifiers.props b/MultiTarget/MultiTargetIdentifiers.props index 632d23e6..bd2f3244 100644 --- a/MultiTarget/MultiTargetIdentifiers.props +++ b/MultiTarget/MultiTargetIdentifiers.props @@ -19,36 +19,36 @@ - true - true - true - true - true - true - true - true - true + true + true + true + true + true + true + true + true + true true - true + true true true - true + true true true - true + true true - true - true + true + true $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) - true - true - true + true + true + true true true diff --git a/MultiTarget/MultiTargetToTargetFramework.props b/MultiTarget/MultiTargetToTargetFramework.props deleted file mode 100644 index 66819d5f..00000000 --- a/MultiTarget/MultiTargetToTargetFramework.props +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - - $(TargetFrameworks);$(UwpTargetFramework) - $(TargetFrameworks);$(WinAppSdkTargetFramework) - - - $(TargetFrameworks);$(DotnetCommonTargetFramework) - $(TargetFrameworks);$(MacOSLibTargetFramework) - $(TargetFrameworks);$(iOSLibTargetFramework) - $(TargetFrameworks);$(AndroidLibTargetFramework) - - $(TargetFrameworks);$(DotnetStandardCommonTargetFramework) - - diff --git a/MultiTarget/UseTargetFrameworks.ps1 b/MultiTarget/UseTargetFrameworks.ps1 index 2f84ee54..568e15d6 100644 --- a/MultiTarget/UseTargetFrameworks.ps1 +++ b/MultiTarget/UseTargetFrameworks.ps1 @@ -31,87 +31,31 @@ Param ( [string[]]$ExcludeMultiTargets = @() # default settings ) -$UwpTfm = "UwpTargetFramework"; -$WinAppSdkTfm = "WinAppSdkTargetFramework"; -$WasmTfm = "DotnetCommonTargetFramework"; -$WpfTfm = "DotnetCommonTargetFramework"; -$GtkTfm = "DotnetCommonTargetFramework"; -$macOSTfm = "MacOSLibTargetFramework"; -$iOSTfm = "iOSLibTargetFramework"; -$DroidTfm = "AndroidLibTargetFramework"; -$NetstandardTfm = "DotnetStandardCommonTargetFramework"; - -$fileContents = Get-Content -Path $PSScriptRoot/AvailableTargetFrameworks.props +$fileContents = Get-Content -Path $PSScriptRoot/EnabledMultiTargets.props $newFileContents = $fileContents; -# 'all' represents many '$MultiTargets' values -if ($MultiTargets.Contains("all")) { - $MultiTargets = @('wasm', 'uwp', 'wasdk', 'wpf', 'linuxgtk', 'macos', 'ios', 'android', 'netstandard') -} +$AllMultiTargets = @('wasm', 'uwp', 'wasdk', 'wpf', 'linuxgtk', 'macos', 'ios', 'android', 'netstandard') # Exclude as needed foreach ($excluded in $ExcludeMultiTargets) { $MultiTargets = $MultiTargets.Where({ $_ -ne $excluded }); } -Write-Output "Setting enabled TargetFrameworks: $MultiTargets" - -$desiredTfmValues = @(); - -if ($MultiTargets.Contains("wasm")) { - $desiredTfmValues += $WasmTfm; -} +Write-Output "Setting enabled MultiTargets: $MultiTargets" -if ($MultiTargets.Contains("uwp")) { - $desiredTfmValues += $UwpTfm; -} - -if ($MultiTargets.Contains("wasdk")) { - $desiredTfmValues += $WinAppSdkTfm; -} - -if ($MultiTargets.Contains("wpf")) { - $desiredTfmValues += $WpfTfm; -} - -if ($MultiTargets.Contains("linuxgtk")) { - $desiredTfmValues += $GtkTfm; -} - -if ($MultiTargets.Contains("macos")) { - $desiredTfmValues += $macOSTfm; -} - -if ($MultiTargets.Contains("ios")) { - $desiredTfmValues += $iOSTfm; +# 'all' represents all available '$MultiTargets' values +if ($MultiTargets.Contains("all")) { + $enabledMultiTargets = @('$(AvailableMultiTargets)') } - -if ($MultiTargets.Contains("android")) { - $desiredTfmValues += $DroidTfm; +else { + $enabledMultiTargets = $AllMultiTargets.Where({ $MultiTargets.Contains($_) }) -join ";" } -if ($MultiTargets.Contains("netstandard")) { - $desiredTfmValues += $NetstandardTfm; -} - -$targetFrameworksToRemove = @( - $WasmTfm, - $UwpTfm, - $WinAppSdkTfm, - $WpfTfm, - $GtkTfm, - $macOSTfm, - $iOSTfm, - $DroidTfm, - $NetstandardTfm -).Where({ -not $desiredTfmValues.Contains($_) }) - -# When targetFrameworksToRemoveRegexPartial is empty, the regex will match everything. +# When enabledMultiTargetsRegexPartial is empty, the regex will match everything. # To work around this, check if there's anything to remove before doing it. -if ($targetFrameworksToRemove.Length -gt 0) { - $targetFrameworksToRemoveRegexPartial = "$($targetFrameworksToRemove -join "|")"; - $newFileContents = $fileContents -replace "<(?:$targetFrameworksToRemoveRegexPartial).+?>.+?>", ''; +if ($enabledMultiTargets.Length -gt 0) { + $newFileContents = $fileContents -replace "\(.+?)\<\/EnabledMultiTargets\>", "$enabledMultiTargets"; } -Set-Content -Force -Path $PSScriptRoot/EnabledTargetFrameworks.props -Value $newFileContents; +Set-Content -Force -Path $PSScriptRoot/EnabledMultiTargets.props -Value $newFileContents; Write-Output "Done. Please close and regenerate your solution. Do not commit these changes to the tooling repository." \ No newline at end of file diff --git a/ProjectHeads/AllComponents/Wasdk/CommunityToolkit.App.Wasdk.csproj b/ProjectHeads/AllComponents/Wasdk/CommunityToolkit.App.Wasdk.csproj index 2808bfd3..ed800138 100644 --- a/ProjectHeads/AllComponents/Wasdk/CommunityToolkit.App.Wasdk.csproj +++ b/ProjectHeads/AllComponents/Wasdk/CommunityToolkit.App.Wasdk.csproj @@ -9,7 +9,10 @@ true + + + diff --git a/ProjectHeads/AllComponents/Wasm/CommunityToolkit.App.Wasm.csproj b/ProjectHeads/AllComponents/Wasm/CommunityToolkit.App.Wasm.csproj index cb846c4d..f1bc44a9 100644 --- a/ProjectHeads/AllComponents/Wasm/CommunityToolkit.App.Wasm.csproj +++ b/ProjectHeads/AllComponents/Wasm/CommunityToolkit.App.Wasm.csproj @@ -8,9 +8,13 @@ true true + wasm + + + diff --git a/ProjectHeads/App.Head.Uwp.props b/ProjectHeads/App.Head.Uwp.props index 1e5bc91c..a2230460 100644 --- a/ProjectHeads/App.Head.Uwp.props +++ b/ProjectHeads/App.Head.Uwp.props @@ -2,7 +2,7 @@ - $(UwpTargetFramework.Split(';')[0]) + $(UwpTargetFrameworks.Split(';')[0]) Uwp diff --git a/ProjectHeads/Head.WinAppSdk.props b/ProjectHeads/Head.WinAppSdk.props index 8df952db..35068376 100644 --- a/ProjectHeads/Head.WinAppSdk.props +++ b/ProjectHeads/Head.WinAppSdk.props @@ -1,7 +1,7 @@ WinExe - $(WinAppSdkTargetFramework.Split(';')[0]) + $(WinAppSdkTargetFrameworks.Split(';')[0]) x86;x64;arm64 win-$(Platform).pubxml true From a7ac78e66629e5c3daaebc28342804dc2a570036 Mon Sep 17 00:00:00 2001 From: Arlo Date: Fri, 20 Dec 2024 15:03:19 -0600 Subject: [PATCH 2/7] Fix MultiTarget imports in all project heads --- .../Tests.Uwp/CommunityToolkit.Tests.Uwp.csproj | 3 +++ .../Tests.Wasdk/CommunityToolkit.Tests.Wasdk.csproj | 3 +++ .../Tests.Uwp/ProjectTemplate.Tests.Uwp.csproj | 3 +++ .../Tests.Wasdk/ProjectTemplate.Tests.Wasdk.csproj | 3 +++ ProjectHeads/SingleComponent/Uwp/ProjectTemplate.Uwp.csproj | 3 +++ .../SingleComponent/Wasdk/ProjectTemplate.Wasdk.csproj | 5 ++++- .../SingleComponent/Wasm/ProjectTemplate.Wasm.csproj | 5 ++++- 7 files changed, 23 insertions(+), 2 deletions(-) diff --git a/ProjectHeads/AllComponents/Tests.Uwp/CommunityToolkit.Tests.Uwp.csproj b/ProjectHeads/AllComponents/Tests.Uwp/CommunityToolkit.Tests.Uwp.csproj index b0d2b247..4c9ad813 100644 --- a/ProjectHeads/AllComponents/Tests.Uwp/CommunityToolkit.Tests.Uwp.csproj +++ b/ProjectHeads/AllComponents/Tests.Uwp/CommunityToolkit.Tests.Uwp.csproj @@ -9,7 +9,10 @@ 2 + + + diff --git a/ProjectHeads/AllComponents/Tests.Wasdk/CommunityToolkit.Tests.Wasdk.csproj b/ProjectHeads/AllComponents/Tests.Wasdk/CommunityToolkit.Tests.Wasdk.csproj index 4dc9d99b..01c0a936 100644 --- a/ProjectHeads/AllComponents/Tests.Wasdk/CommunityToolkit.Tests.Wasdk.csproj +++ b/ProjectHeads/AllComponents/Tests.Wasdk/CommunityToolkit.Tests.Wasdk.csproj @@ -7,7 +7,10 @@ 3 + + + diff --git a/ProjectHeads/SingleComponent/Tests.Uwp/ProjectTemplate.Tests.Uwp.csproj b/ProjectHeads/SingleComponent/Tests.Uwp/ProjectTemplate.Tests.Uwp.csproj index 86fdc50d..8e90b9ea 100644 --- a/ProjectHeads/SingleComponent/Tests.Uwp/ProjectTemplate.Tests.Uwp.csproj +++ b/ProjectHeads/SingleComponent/Tests.Uwp/ProjectTemplate.Tests.Uwp.csproj @@ -11,7 +11,10 @@ true + + + diff --git a/ProjectHeads/SingleComponent/Tests.Wasdk/ProjectTemplate.Tests.Wasdk.csproj b/ProjectHeads/SingleComponent/Tests.Wasdk/ProjectTemplate.Tests.Wasdk.csproj index d57ef304..872db0c3 100644 --- a/ProjectHeads/SingleComponent/Tests.Wasdk/ProjectTemplate.Tests.Wasdk.csproj +++ b/ProjectHeads/SingleComponent/Tests.Wasdk/ProjectTemplate.Tests.Wasdk.csproj @@ -9,7 +9,10 @@ true + + + diff --git a/ProjectHeads/SingleComponent/Uwp/ProjectTemplate.Uwp.csproj b/ProjectHeads/SingleComponent/Uwp/ProjectTemplate.Uwp.csproj index fcd81198..4b86ee92 100644 --- a/ProjectHeads/SingleComponent/Uwp/ProjectTemplate.Uwp.csproj +++ b/ProjectHeads/SingleComponent/Uwp/ProjectTemplate.Uwp.csproj @@ -11,7 +11,10 @@ true + + + diff --git a/ProjectHeads/SingleComponent/Wasdk/ProjectTemplate.Wasdk.csproj b/ProjectHeads/SingleComponent/Wasdk/ProjectTemplate.Wasdk.csproj index 55b62098..debf076c 100644 --- a/ProjectHeads/SingleComponent/Wasdk/ProjectTemplate.Wasdk.csproj +++ b/ProjectHeads/SingleComponent/Wasdk/ProjectTemplate.Wasdk.csproj @@ -10,7 +10,10 @@ true - + + + + diff --git a/ProjectHeads/SingleComponent/Wasm/ProjectTemplate.Wasm.csproj b/ProjectHeads/SingleComponent/Wasm/ProjectTemplate.Wasm.csproj index 25f62528..701313e8 100644 --- a/ProjectHeads/SingleComponent/Wasm/ProjectTemplate.Wasm.csproj +++ b/ProjectHeads/SingleComponent/Wasm/ProjectTemplate.Wasm.csproj @@ -11,8 +11,11 @@ - + + + + From 70367248a887c29d9af8c85eafb1276150b31346 Mon Sep 17 00:00:00 2001 From: Arlo Date: Fri, 20 Dec 2024 14:46:10 -0600 Subject: [PATCH 3/7] Rewired and cleaned up "Available" vs "Enabled" MultiTargets and TargetFrameworks. Lifted TFM toggling above TFM declarations into MultiTarget system, enables overriding "Available" TargetFrameworks properly per-project. --- Build-Toolkit-Components.ps1 | 8 +- MultiTarget/AvailableMultiTargets.props | 18 +++++ MultiTarget/AvailableTargetFrameworks.props | 23 +++--- MultiTarget/EnabledMultiTargets.props | 13 +-- MultiTarget/EnabledTargetFrameworks.props | 45 ++++++----- MultiTarget/Library.props | 9 ++- MultiTarget/MultiTargetIdentifiers.props | 34 ++++---- .../MultiTargetToTargetFramework.props | 31 ------- MultiTarget/UseTargetFrameworks.ps1 | 80 +++---------------- .../Wasdk/CommunityToolkit.App.Wasdk.csproj | 3 + .../Wasm/CommunityToolkit.App.Wasm.csproj | 4 + ProjectHeads/App.Head.Uwp.props | 2 +- ProjectHeads/Head.WinAppSdk.props | 2 +- 13 files changed, 105 insertions(+), 167 deletions(-) create mode 100644 MultiTarget/AvailableMultiTargets.props delete mode 100644 MultiTarget/MultiTargetToTargetFramework.props diff --git a/Build-Toolkit-Components.ps1 b/Build-Toolkit-Components.ps1 index c461bddd..97dface1 100644 --- a/Build-Toolkit-Components.ps1 +++ b/Build-Toolkit-Components.ps1 @@ -95,6 +95,10 @@ Param ( [switch]$Verbose ) +# Use the specified MultiTarget TFM and WinUI version +& $PSScriptRoot\MultiTarget\UseUnoWinUI.ps1 $WinUIMajorVersion +& $PSScriptRoot\MultiTarget\UseTargetFrameworks.ps1 -MultiTargets $MultiTargets -ExcludeMultiTargets $ExcludeMultiTargets + if ($MultiTargets -eq 'all') { $MultiTargets = @('wasm', 'uwp', 'wasdk', 'wpf', 'linuxgtk', 'macos', 'ios', 'android', 'netstandard') } @@ -128,10 +132,6 @@ if ($ExcludeComponents) { $Components = $Components | Where-Object { $_ -notin $ExcludeComponents } } -# Use the specified MultiTarget TFM and WinUI version -& $PSScriptRoot\MultiTarget\UseTargetFrameworks.ps1 $MultiTargets -& $PSScriptRoot\MultiTarget\UseUnoWinUI.ps1 $WinUIMajorVersion - function Invoke-MSBuildWithBinlog { param ( [string]$TargetHeadPath diff --git a/MultiTarget/AvailableMultiTargets.props b/MultiTarget/AvailableMultiTargets.props new file mode 100644 index 00000000..efd9fe51 --- /dev/null +++ b/MultiTarget/AvailableMultiTargets.props @@ -0,0 +1,18 @@ + + + + true + + + + + + + + + + + + $(AvailableMultiTargets);$(MultiTarget) + + diff --git a/MultiTarget/AvailableTargetFrameworks.props b/MultiTarget/AvailableTargetFrameworks.props index 9d9b5869..5f548aad 100644 --- a/MultiTarget/AvailableTargetFrameworks.props +++ b/MultiTarget/AvailableTargetFrameworks.props @@ -1,22 +1,27 @@ + - uap10.0.17763; - uap10.0.17763;net8.0-windows10.0.26100.0; - net9.0-windows10.0.19041.0;net8.0-windows10.0.19041.0; + uap10.0.17763; + uap10.0.17763;net8.0-windows10.0.26100.0; + net9.0-windows10.0.19041.0;net8.0-windows10.0.19041.0; net9.0; net9.0; net9.0; - net9.0-android; - net9.0-maccatalyst; - net9.0-ios; + net9.0-android; + net9.0-maccatalyst; + net9.0-ios; - net9.0; - net9.0; - net9.0; + net9.0; + net9.0; + net9.0; netstandard2.0 diff --git a/MultiTarget/EnabledMultiTargets.props b/MultiTarget/EnabledMultiTargets.props index 3781585e..47de0231 100644 --- a/MultiTarget/EnabledMultiTargets.props +++ b/MultiTarget/EnabledMultiTargets.props @@ -1,14 +1,7 @@ - + + - true + wasm;uwp;netstandard - - - - - - - - diff --git a/MultiTarget/EnabledTargetFrameworks.props b/MultiTarget/EnabledTargetFrameworks.props index 93819344..6f1c0ab9 100644 --- a/MultiTarget/EnabledTargetFrameworks.props +++ b/MultiTarget/EnabledTargetFrameworks.props @@ -1,25 +1,26 @@ - - - - uap10.0.17763; - uap10.0.17763;net8.0-windows10.0.26100.0; - - - net9.0; - net9.0; - net9.0; - - - - + + + + $(TargetFrameworks);$(UwpTargetFrameworks) + $(TargetFrameworks);$(WinAppSdkTargetFrameworks) - - net9.0; - net9.0; - net9.0; + + true + true + $(TargetFrameworks);$(DotnetCommonTargetFramework) - - netstandard2.0 - net9.0; - + $(TargetFrameworks);$(MacOSLibTargetFrameworks) + $(TargetFrameworks);$(iOSLibTargetFrameworks) + $(TargetFrameworks);$(AndroidLibTargetFrameworks) + + $(TargetFrameworks);$(DotnetStandardCommonTargetFramework) + diff --git a/MultiTarget/Library.props b/MultiTarget/Library.props index eb6e079e..61ab36c8 100644 --- a/MultiTarget/Library.props +++ b/MultiTarget/Library.props @@ -5,13 +5,14 @@ false - + + + + - - - + diff --git a/MultiTarget/MultiTargetIdentifiers.props b/MultiTarget/MultiTargetIdentifiers.props index b3593f37..efc95a9f 100644 --- a/MultiTarget/MultiTargetIdentifiers.props +++ b/MultiTarget/MultiTargetIdentifiers.props @@ -19,36 +19,36 @@ - true - true - true - true - true - true - true - true - true + true + true + true + true + true + true + true + true + true true - true + true true true - true + true true true - true + true true - true - true + true + true $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) - true - true - true + true + true + true true true diff --git a/MultiTarget/MultiTargetToTargetFramework.props b/MultiTarget/MultiTargetToTargetFramework.props deleted file mode 100644 index 66819d5f..00000000 --- a/MultiTarget/MultiTargetToTargetFramework.props +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - - $(TargetFrameworks);$(UwpTargetFramework) - $(TargetFrameworks);$(WinAppSdkTargetFramework) - - - $(TargetFrameworks);$(DotnetCommonTargetFramework) - $(TargetFrameworks);$(MacOSLibTargetFramework) - $(TargetFrameworks);$(iOSLibTargetFramework) - $(TargetFrameworks);$(AndroidLibTargetFramework) - - $(TargetFrameworks);$(DotnetStandardCommonTargetFramework) - - diff --git a/MultiTarget/UseTargetFrameworks.ps1 b/MultiTarget/UseTargetFrameworks.ps1 index 2f84ee54..568e15d6 100644 --- a/MultiTarget/UseTargetFrameworks.ps1 +++ b/MultiTarget/UseTargetFrameworks.ps1 @@ -31,87 +31,31 @@ Param ( [string[]]$ExcludeMultiTargets = @() # default settings ) -$UwpTfm = "UwpTargetFramework"; -$WinAppSdkTfm = "WinAppSdkTargetFramework"; -$WasmTfm = "DotnetCommonTargetFramework"; -$WpfTfm = "DotnetCommonTargetFramework"; -$GtkTfm = "DotnetCommonTargetFramework"; -$macOSTfm = "MacOSLibTargetFramework"; -$iOSTfm = "iOSLibTargetFramework"; -$DroidTfm = "AndroidLibTargetFramework"; -$NetstandardTfm = "DotnetStandardCommonTargetFramework"; - -$fileContents = Get-Content -Path $PSScriptRoot/AvailableTargetFrameworks.props +$fileContents = Get-Content -Path $PSScriptRoot/EnabledMultiTargets.props $newFileContents = $fileContents; -# 'all' represents many '$MultiTargets' values -if ($MultiTargets.Contains("all")) { - $MultiTargets = @('wasm', 'uwp', 'wasdk', 'wpf', 'linuxgtk', 'macos', 'ios', 'android', 'netstandard') -} +$AllMultiTargets = @('wasm', 'uwp', 'wasdk', 'wpf', 'linuxgtk', 'macos', 'ios', 'android', 'netstandard') # Exclude as needed foreach ($excluded in $ExcludeMultiTargets) { $MultiTargets = $MultiTargets.Where({ $_ -ne $excluded }); } -Write-Output "Setting enabled TargetFrameworks: $MultiTargets" - -$desiredTfmValues = @(); - -if ($MultiTargets.Contains("wasm")) { - $desiredTfmValues += $WasmTfm; -} +Write-Output "Setting enabled MultiTargets: $MultiTargets" -if ($MultiTargets.Contains("uwp")) { - $desiredTfmValues += $UwpTfm; -} - -if ($MultiTargets.Contains("wasdk")) { - $desiredTfmValues += $WinAppSdkTfm; -} - -if ($MultiTargets.Contains("wpf")) { - $desiredTfmValues += $WpfTfm; -} - -if ($MultiTargets.Contains("linuxgtk")) { - $desiredTfmValues += $GtkTfm; -} - -if ($MultiTargets.Contains("macos")) { - $desiredTfmValues += $macOSTfm; -} - -if ($MultiTargets.Contains("ios")) { - $desiredTfmValues += $iOSTfm; +# 'all' represents all available '$MultiTargets' values +if ($MultiTargets.Contains("all")) { + $enabledMultiTargets = @('$(AvailableMultiTargets)') } - -if ($MultiTargets.Contains("android")) { - $desiredTfmValues += $DroidTfm; +else { + $enabledMultiTargets = $AllMultiTargets.Where({ $MultiTargets.Contains($_) }) -join ";" } -if ($MultiTargets.Contains("netstandard")) { - $desiredTfmValues += $NetstandardTfm; -} - -$targetFrameworksToRemove = @( - $WasmTfm, - $UwpTfm, - $WinAppSdkTfm, - $WpfTfm, - $GtkTfm, - $macOSTfm, - $iOSTfm, - $DroidTfm, - $NetstandardTfm -).Where({ -not $desiredTfmValues.Contains($_) }) - -# When targetFrameworksToRemoveRegexPartial is empty, the regex will match everything. +# When enabledMultiTargetsRegexPartial is empty, the regex will match everything. # To work around this, check if there's anything to remove before doing it. -if ($targetFrameworksToRemove.Length -gt 0) { - $targetFrameworksToRemoveRegexPartial = "$($targetFrameworksToRemove -join "|")"; - $newFileContents = $fileContents -replace "<(?:$targetFrameworksToRemoveRegexPartial).+?>.+?>", ''; +if ($enabledMultiTargets.Length -gt 0) { + $newFileContents = $fileContents -replace "\(.+?)\<\/EnabledMultiTargets\>", "$enabledMultiTargets"; } -Set-Content -Force -Path $PSScriptRoot/EnabledTargetFrameworks.props -Value $newFileContents; +Set-Content -Force -Path $PSScriptRoot/EnabledMultiTargets.props -Value $newFileContents; Write-Output "Done. Please close and regenerate your solution. Do not commit these changes to the tooling repository." \ No newline at end of file diff --git a/ProjectHeads/AllComponents/Wasdk/CommunityToolkit.App.Wasdk.csproj b/ProjectHeads/AllComponents/Wasdk/CommunityToolkit.App.Wasdk.csproj index 2808bfd3..ed800138 100644 --- a/ProjectHeads/AllComponents/Wasdk/CommunityToolkit.App.Wasdk.csproj +++ b/ProjectHeads/AllComponents/Wasdk/CommunityToolkit.App.Wasdk.csproj @@ -9,7 +9,10 @@ true + + + diff --git a/ProjectHeads/AllComponents/Wasm/CommunityToolkit.App.Wasm.csproj b/ProjectHeads/AllComponents/Wasm/CommunityToolkit.App.Wasm.csproj index cb846c4d..f1bc44a9 100644 --- a/ProjectHeads/AllComponents/Wasm/CommunityToolkit.App.Wasm.csproj +++ b/ProjectHeads/AllComponents/Wasm/CommunityToolkit.App.Wasm.csproj @@ -8,9 +8,13 @@ true true + wasm + + + diff --git a/ProjectHeads/App.Head.Uwp.props b/ProjectHeads/App.Head.Uwp.props index 1e5bc91c..a2230460 100644 --- a/ProjectHeads/App.Head.Uwp.props +++ b/ProjectHeads/App.Head.Uwp.props @@ -2,7 +2,7 @@ - $(UwpTargetFramework.Split(';')[0]) + $(UwpTargetFrameworks.Split(';')[0]) Uwp diff --git a/ProjectHeads/Head.WinAppSdk.props b/ProjectHeads/Head.WinAppSdk.props index 8df952db..35068376 100644 --- a/ProjectHeads/Head.WinAppSdk.props +++ b/ProjectHeads/Head.WinAppSdk.props @@ -1,7 +1,7 @@ WinExe - $(WinAppSdkTargetFramework.Split(';')[0]) + $(WinAppSdkTargetFrameworks.Split(';')[0]) x86;x64;arm64 win-$(Platform).pubxml true From b7521ef5a8cfb3ca6148a1ccde9cfd5c646d8075 Mon Sep 17 00:00:00 2001 From: Arlo Date: Fri, 20 Dec 2024 15:03:19 -0600 Subject: [PATCH 4/7] Fix MultiTarget imports in all project heads --- .../Tests.Uwp/CommunityToolkit.Tests.Uwp.csproj | 3 +++ .../Tests.Wasdk/CommunityToolkit.Tests.Wasdk.csproj | 3 +++ .../Tests.Uwp/ProjectTemplate.Tests.Uwp.csproj | 3 +++ .../Tests.Wasdk/ProjectTemplate.Tests.Wasdk.csproj | 3 +++ ProjectHeads/SingleComponent/Uwp/ProjectTemplate.Uwp.csproj | 3 +++ .../SingleComponent/Wasdk/ProjectTemplate.Wasdk.csproj | 5 ++++- .../SingleComponent/Wasm/ProjectTemplate.Wasm.csproj | 5 ++++- 7 files changed, 23 insertions(+), 2 deletions(-) diff --git a/ProjectHeads/AllComponents/Tests.Uwp/CommunityToolkit.Tests.Uwp.csproj b/ProjectHeads/AllComponents/Tests.Uwp/CommunityToolkit.Tests.Uwp.csproj index b0d2b247..4c9ad813 100644 --- a/ProjectHeads/AllComponents/Tests.Uwp/CommunityToolkit.Tests.Uwp.csproj +++ b/ProjectHeads/AllComponents/Tests.Uwp/CommunityToolkit.Tests.Uwp.csproj @@ -9,7 +9,10 @@ 2 + + + diff --git a/ProjectHeads/AllComponents/Tests.Wasdk/CommunityToolkit.Tests.Wasdk.csproj b/ProjectHeads/AllComponents/Tests.Wasdk/CommunityToolkit.Tests.Wasdk.csproj index 4dc9d99b..01c0a936 100644 --- a/ProjectHeads/AllComponents/Tests.Wasdk/CommunityToolkit.Tests.Wasdk.csproj +++ b/ProjectHeads/AllComponents/Tests.Wasdk/CommunityToolkit.Tests.Wasdk.csproj @@ -7,7 +7,10 @@ 3 + + + diff --git a/ProjectHeads/SingleComponent/Tests.Uwp/ProjectTemplate.Tests.Uwp.csproj b/ProjectHeads/SingleComponent/Tests.Uwp/ProjectTemplate.Tests.Uwp.csproj index 86fdc50d..8e90b9ea 100644 --- a/ProjectHeads/SingleComponent/Tests.Uwp/ProjectTemplate.Tests.Uwp.csproj +++ b/ProjectHeads/SingleComponent/Tests.Uwp/ProjectTemplate.Tests.Uwp.csproj @@ -11,7 +11,10 @@ true + + + diff --git a/ProjectHeads/SingleComponent/Tests.Wasdk/ProjectTemplate.Tests.Wasdk.csproj b/ProjectHeads/SingleComponent/Tests.Wasdk/ProjectTemplate.Tests.Wasdk.csproj index d57ef304..872db0c3 100644 --- a/ProjectHeads/SingleComponent/Tests.Wasdk/ProjectTemplate.Tests.Wasdk.csproj +++ b/ProjectHeads/SingleComponent/Tests.Wasdk/ProjectTemplate.Tests.Wasdk.csproj @@ -9,7 +9,10 @@ true + + + diff --git a/ProjectHeads/SingleComponent/Uwp/ProjectTemplate.Uwp.csproj b/ProjectHeads/SingleComponent/Uwp/ProjectTemplate.Uwp.csproj index fcd81198..4b86ee92 100644 --- a/ProjectHeads/SingleComponent/Uwp/ProjectTemplate.Uwp.csproj +++ b/ProjectHeads/SingleComponent/Uwp/ProjectTemplate.Uwp.csproj @@ -11,7 +11,10 @@ true + + + diff --git a/ProjectHeads/SingleComponent/Wasdk/ProjectTemplate.Wasdk.csproj b/ProjectHeads/SingleComponent/Wasdk/ProjectTemplate.Wasdk.csproj index 55b62098..debf076c 100644 --- a/ProjectHeads/SingleComponent/Wasdk/ProjectTemplate.Wasdk.csproj +++ b/ProjectHeads/SingleComponent/Wasdk/ProjectTemplate.Wasdk.csproj @@ -10,7 +10,10 @@ true - + + + + diff --git a/ProjectHeads/SingleComponent/Wasm/ProjectTemplate.Wasm.csproj b/ProjectHeads/SingleComponent/Wasm/ProjectTemplate.Wasm.csproj index 25f62528..701313e8 100644 --- a/ProjectHeads/SingleComponent/Wasm/ProjectTemplate.Wasm.csproj +++ b/ProjectHeads/SingleComponent/Wasm/ProjectTemplate.Wasm.csproj @@ -11,8 +11,11 @@ - + + + + From 13a841d2341fe7d08c616a20feafbd84cab099f5 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sat, 21 Dec 2024 18:25:10 +0100 Subject: [PATCH 5/7] Add 'net9.0-windows10.0.26100.0' TFM to UWP --- MultiTarget/AvailableTargetFrameworks.props | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/MultiTarget/AvailableTargetFrameworks.props b/MultiTarget/AvailableTargetFrameworks.props index 5f548aad..7d5afb3d 100644 --- a/MultiTarget/AvailableTargetFrameworks.props +++ b/MultiTarget/AvailableTargetFrameworks.props @@ -7,7 +7,9 @@ uap10.0.17763; - uap10.0.17763;net8.0-windows10.0.26100.0; + + + uap10.0.17763;net8.0-windows10.0.26100.0;net9.0-windows10.0.26100.0; net9.0-windows10.0.19041.0;net8.0-windows10.0.19041.0; net9.0; From b36a5a9a2255cebb1e4e23af90ef7fd96c5afc84 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sat, 21 Dec 2024 19:18:41 +0100 Subject: [PATCH 6/7] Fix 'UseUwp' condition --- MultiTarget/MultiTargetIdentifiers.props | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/MultiTarget/MultiTargetIdentifiers.props b/MultiTarget/MultiTargetIdentifiers.props index efc95a9f..a16f7190 100644 --- a/MultiTarget/MultiTargetIdentifiers.props +++ b/MultiTarget/MultiTargetIdentifiers.props @@ -64,6 +64,11 @@ false true - true + + true From 2929e6da18dc25389940e1c340a8d844fa8fb124 Mon Sep 17 00:00:00 2001 From: Arlo Date: Mon, 23 Dec 2024 12:19:04 -0600 Subject: [PATCH 7/7] Added missing DefinedConstants import --- ProjectHeads/SingleComponent/Wasdk/ProjectTemplate.Wasdk.csproj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ProjectHeads/SingleComponent/Wasdk/ProjectTemplate.Wasdk.csproj b/ProjectHeads/SingleComponent/Wasdk/ProjectTemplate.Wasdk.csproj index debf076c..763fd650 100644 --- a/ProjectHeads/SingleComponent/Wasdk/ProjectTemplate.Wasdk.csproj +++ b/ProjectHeads/SingleComponent/Wasdk/ProjectTemplate.Wasdk.csproj @@ -14,6 +14,8 @@ + +