5959Param (
6060 [ValidateSet (' all' , ' wasm' , ' uwp' , ' wasdk' , ' wpf' , ' linuxgtk' , ' macos' , ' ios' , ' android' , ' netstandard' )]
6161 [Alias (" mt" )]
62- [string []]$MultiTargets = @ (' uwp' , ' wasm' ), # default settings
62+ [string []]$MultiTargets = @ (' uwp' , ' wasm' , ' wasdk ' ), # default settings
6363
6464 [ValidateSet (' wasm' , ' uwp' , ' wasdk' , ' wpf' , ' linuxgtk' , ' macos' , ' ios' , ' android' , ' netstandard' )]
6565 [string []]$ExcludeMultiTargets = @ (), # default settings
@@ -85,7 +85,7 @@ Param (
8585 [hashtable ]$AdditionalProperties ,
8686
8787 [Alias (" winui" )]
88- [int ]$WinUIMajorVersion = 2 ,
88+ [int ]$WinUIMajorVersion = 3 ,
8989
9090 [string ]$ComponentDir = " src" ,
9191
@@ -95,9 +95,6 @@ Param (
9595 [switch ]$Verbose
9696)
9797
98- # Use the specified MultiTarget TFM and WinUI version
99- & $PSScriptRoot \MultiTarget\UseUnoWinUI.ps1 $WinUIMajorVersion
100- & $PSScriptRoot \MultiTarget\UseTargetFrameworks.ps1 - MultiTargets $MultiTargets - ExcludeMultiTargets $ExcludeMultiTargets
10198
10299if ($MultiTargets -eq ' all' ) {
103100 $MultiTargets = @ (' wasm' , ' uwp' , ' wasdk' , ' wpf' , ' linuxgtk' , ' macos' , ' ios' , ' android' , ' netstandard' )
@@ -110,28 +107,32 @@ if ($null -eq $ExcludeMultiTargets)
110107
111108# Both uwp and wasdk share a targetframework. Both cannot be enabled at once.
112109# If both are supplied, remove one based on WinUIMajorVersion.
113- if ($MultiTargets .Contains ( ' uwp ' ) -and $MultiTargets .Contains ( ' wasdk ' ) )
110+ if ($WinUIMajorVersion -eq 2 )
114111{
115- if ($WinUIMajorVersion -eq 2 )
116- {
117- $ExcludeMultiTargets = $ExcludeMultiTargets + ' wasdk'
118- }
119- else
120- {
121- $ExcludeMultiTargets = $ExcludeMultiTargets + ' uwp'
122- }
112+ $ExcludeMultiTargets = $ExcludeMultiTargets + ' wasdk'
113+ }
114+
115+ if ($WinUIMajorVersion -eq 3 )
116+ {
117+ $ExcludeMultiTargets = $ExcludeMultiTargets + ' uwp'
123118}
124119
125120$MultiTargets = $MultiTargets | Where-Object { $_ -notin $ExcludeMultiTargets }
126121
127- if ($Components -eq @ (' all' )) {
128- $Components = @ (' **' )
129- }
122+ Write-Output " Building components '$Components ' for MultiTargets: $MultiTargets "
130123
131124if ($ExcludeComponents ) {
132125 $Components = $Components | Where-Object { $_ -notin $ExcludeComponents }
133126}
134127
128+ # Use the specified MultiTarget TFM and WinUI version
129+ # WinUI 0 indicates non-WinUI projects (e.g. netstandard) should be built.
130+ if ($WinUIMajorVersion -ne 0 ) {
131+ & $PSScriptRoot \MultiTarget\UseUnoWinUI.ps1 $WinUIMajorVersion
132+ }
133+
134+ & $PSScriptRoot \MultiTarget\UseTargetFrameworks.ps1 - MultiTargets $MultiTargets - ExcludeMultiTargets $ExcludeMultiTargets
135+
135136function Invoke-MSBuildWithBinlog {
136137 param (
137138 [string ]$TargetHeadPath
@@ -207,11 +208,9 @@ function Invoke-MSBuildWithBinlog {
207208 }
208209}
209210
210- # List of WinUI-2 compatible multitargets
211- $WinUI2MultiTargets = @ (' uwp' , ' wasm' , ' wpf' , ' linuxgtk' , ' macos' , ' ios' , ' android' )
212-
213- # List of WinUI-3 compatible multitargets
214- $WinUI3MultiTargets = @ (' wasdk' , ' wasm' , ' wpf' , ' linuxgtk' , ' macos' , ' ios' , ' android' )
211+ if ($Components -eq @ (' all' )) {
212+ $Components = @ (' **' )
213+ }
215214
216215# Components are built individually
217216foreach ($ComponentName in $Components ) {
@@ -228,40 +227,21 @@ foreach ($ComponentName in $Components) {
228227 # Get supported MultiTarget for this component
229228 $supportedMultiTargets = & $PSScriptRoot \MultiTarget\Get-MultiTargets.ps1 - component $componentName
230229
231- # If the component does not support at least one target that supports the requested WinUI major version, skip the component
232- $isWinUIMajorVersionSupported = $false
233-
234- # Flag to check if any of the requested targets are supported by the component
235- $isRequestedTargetSupported = $false
236-
237- foreach ($requestedTarget in $MultiTargets ) {
238- if ($false -eq $isRequestedTargetSupported ) {
239- $isRequestedTargetSupported = $requestedTarget -in $supportedMultiTargets
240- }
241- }
242-
243- foreach ($supportedMultiTarget in $supportedMultiTargets ) {
244- if ($false -eq $isWinUIMajorVersionSupported ) {
245- if ($WinUIMajorVersion -eq 2 ) {
246- $isWinUIMajorVersionSupported = $supportedMultiTarget -in $WinUI2MultiTargets ;
247- }
248-
249- if ($WinUIMajorVersion -eq 3 ) {
250- $isWinUIMajorVersionSupported = $supportedMultiTarget -in $WinUI3MultiTargets ;
251- }
252- }
253- }
254-
255- # If none of the requested targets are supported by the component, we can skip build to save time and avoid errors.
256- if (-not $isRequestedTargetSupported ) {
257- Write-Warning " Skipping $ ( $componentPath.BaseName ) , none of the requested MultiTargets '$MultiTargets ' are enabled for this component."
230+ $shouldBuild = & $PSScriptRoot \MultiTarget\Test-Component - Support.ps1 `
231+ - RequestedMultiTargets $MultiTargets `
232+ - SupportedMultiTargets $supportedMultiTargets `
233+ - Component $componentName `
234+ - WinUIMajorVersion $WinUIMajorVersion
235+
236+ if (-not $shouldBuild.IsSupported ) {
237+ Write-Warning " Skipping $componentName . $ ( $shouldBuild.Reason ) "
258238 continue
259239 }
260240
261- if ( -not $isWinUIMajorVersionSupported ) {
262- Write-Warning " Skipping $ ( $componentPath .BaseName ) , none of the supported MultiTargets ' $supportedMultiTargets ' support WinUI $WinUIMajorVersion . "
263- continue
264- }
241+ # Filter ExcludeMultiTargets out of supportedMultiTargets
242+ # For display purposes only. The actual build uses the EnabledMultiTargets.props + EnabledTargetFrameworks.props to calculate supported targets at build time.
243+ $supportedMultiTargets = $supportedMultiTargets | Where-Object { $_ -notin $ExcludeMultiTargets }
244+ Write-Output " Building $componentName for MultiTargets ' $supportedMultiTargets ' "
265245
266246 Invoke-MSBuildWithBinlog $componentCsproj.FullName $EnableBinLogs $BinlogOutput
267247 }
0 commit comments