Skip to content

Commit 0054ba3

Browse files
committed
Add support for requesting WinUI 0 (non-WinUI) components be build. For use by packaging CI matrix.
1 parent 060d805 commit 0054ba3

File tree

1 file changed

+40
-15
lines changed

1 file changed

+40
-15
lines changed

Build-Toolkit-Components.ps1

Lines changed: 40 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,11 @@ Param (
9696
)
9797

9898
# Use the specified MultiTarget TFM and WinUI version
99-
& $PSScriptRoot\MultiTarget\UseUnoWinUI.ps1 $WinUIMajorVersion
99+
# WinUI 0 indicates non-WinUI projects (e.g. netstandard) should be built.
100+
if ($WinUIMajorVersion -ne 0) {
101+
& $PSScriptRoot\MultiTarget\UseUnoWinUI.ps1 $WinUIMajorVersion
102+
}
103+
100104
& $PSScriptRoot\MultiTarget\UseTargetFrameworks.ps1 -MultiTargets $MultiTargets -ExcludeMultiTargets $ExcludeMultiTargets
101105

102106
if ($MultiTargets -eq 'all') {
@@ -116,7 +120,7 @@ if ($MultiTargets.Contains('uwp') -and $MultiTargets.Contains('wasdk'))
116120
{
117121
$ExcludeMultiTargets = $ExcludeMultiTargets + 'wasdk'
118122
}
119-
else
123+
elseif ($WinUIMajorVersion -eq 3)
120124
{
121125
$ExcludeMultiTargets = $ExcludeMultiTargets + 'uwp'
122126
}
@@ -207,6 +211,9 @@ function Invoke-MSBuildWithBinlog {
207211
}
208212
}
209213

214+
# List of WinUI-0 (non-WinUI) compatible multitargets
215+
$WinUI0MultiTargets = @('netstandard')
216+
210217
# List of WinUI-2 compatible multitargets
211218
$WinUI2MultiTargets = @('uwp', 'wasm', 'wpf', 'linuxgtk', 'macos', 'ios', 'android')
212219

@@ -228,8 +235,11 @@ foreach ($ComponentName in $Components) {
228235
# Get supported MultiTarget for this component
229236
$supportedMultiTargets = & $PSScriptRoot\MultiTarget\Get-MultiTargets.ps1 -component $componentName
230237

231-
# If the component does not support at least one target that supports the requested WinUI major version, skip the component
232-
$isWinUIMajorVersionSupported = $false
238+
# If WinUI 0 is requested, the component must not support WinUI 2 or WinUI 3 to be built.
239+
# If WinUI 2 or 3 is requested, the component have a target that supports WinUI 2 or 3 to be built.
240+
$isWinUI0Supported = $false
241+
$isWinUI2Supported = $false
242+
$isWinUI3Supported = $false
233243

234244
# Flag to check if any of the requested targets are supported by the component
235245
$isRequestedTargetSupported = $false
@@ -241,28 +251,43 @@ foreach ($ComponentName in $Components) {
241251
}
242252

243253
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-
}
254+
# Only build components that support WinUI 2
255+
if ($false -eq $isWinUI2Supported) {
256+
$isWinUI2Supported = $supportedMultiTarget -in $WinUI2MultiTargets;
257+
}
258+
259+
# Only build components that support WinUI 3
260+
if ($false -eq $isWinUI3Supported) {
261+
$isWinUI3Supported = $supportedMultiTarget -in $WinUI3MultiTargets;
262+
}
263+
264+
# Build components that support neither WinUI 2 nor WinUI 3 (e.g. netstandard only)
265+
if ($false -eq $isWinUI0Supported) {
266+
$isWinUI0Supported = $supportedMultiTarget -in $WinUI0MultiTargets -and -not ($isWinUI2Supported -or $isWinUI3Supported);
252267
}
253268
}
254269

255270
# If none of the requested targets are supported by the component, we can skip build to save time and avoid errors.
256271
if (-not $isRequestedTargetSupported) {
257-
Write-Warning "Skipping $($componentPath.BaseName), none of the requested MultiTargets '$MultiTargets' are enabled for this component."
272+
Write-Warning "Skipping $componentName, none of the requested MultiTargets '$MultiTargets' are enabled for this component."
258273
continue
259274
}
260275

261-
if (-not $isWinUIMajorVersionSupported) {
262-
Write-Warning "Skipping $($componentPath.BaseName), none of the supported MultiTargets '$supportedMultiTargets' support WinUI $WinUIMajorVersion."
276+
if (-not $isWinUI0Supported -and $WinUIMajorVersion -eq 0) {
277+
Write-Warning "Skipping $componentName. WinUI is disabled and one of the supported MultiTargets '$supportedMultiTargets' supports WinUI."
278+
continue;
279+
}
280+
281+
if ((-not $isWinUI2Supported -and $WinUIMajorVersion -eq 2) -or (-not $isWinUI3Supported -and $WinUIMajorVersion -eq 3)) {
282+
Write-Warning "Skipping $componentName. WinUI $WinUIMajorVersion is enabled and not supported by any of the MultiTargets '$supportedMultiTargets'"
263283
continue
264284
}
265285

286+
# Filter ExcludeMultiTargets out of supportedMultiTargets
287+
# For display purposes only. The actual build uses the EnabledMultiTargets.props + EnabledTargetFrameworks.props to calculate supported targets at build time.
288+
$supportedMultiTargets = $supportedMultiTargets | Where-Object { $_ -notin $ExcludeMultiTargets }
289+
290+
Write-Output "Building $componentName for MultiTargets '$supportedMultiTargets'"
266291
Invoke-MSBuildWithBinlog $componentCsproj.FullName $EnableBinLogs $BinlogOutput
267292
}
268293
}

0 commit comments

Comments
 (0)