Skip to content

Commit

Permalink
Fixed components with non-default MultiTargets being skipped for build
Browse files Browse the repository at this point in the history
  • Loading branch information
Arlodotexe committed Mar 1, 2024
1 parent 229d8fa commit 623cb03
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions Build-Toolkit-Components.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@ Param (
)

if ($MultiTargets -eq 'all') {
$MultiTargets = @('wasm', 'uwp', 'wasdk', 'wpf', 'linuxgtk', 'macos', 'ios', 'android', 'netstandard')
$MultiTargets = @('wasm', 'uwp', 'wasdk', 'wpf', 'linuxgtk', 'macos', 'ios', 'android', 'netstandard')
}

if ($ExcludeMultiTargets -eq $null)
if ($null -eq $ExcludeMultiTargets)
{
$ExcludeMultiTargets = @()
$ExcludeMultiTargets = @()
}

$MultiTargets = $MultiTargets | Where-Object { $_ -notin $ExcludeMultiTargets }
Expand Down Expand Up @@ -175,20 +175,30 @@ function Invoke-MSBuildWithBinlog {

# Components are built individually
foreach ($ComponentName in $Components) {
# Find all components source csproj (when wildcard), or find specific component csproj by name.
# Find all components source csproj (when wildcard), or find specific component csproj by name.
foreach ($componentCsproj in Get-ChildItem -Path "$PSScriptRoot/../components/$ComponentName/$ComponentDir/*.csproj") {
# Get component name from csproj path
$componentPath = Get-Item "$componentCsproj/../../"

# Get supported MultiTarget for this component
$supportedMultiTargets = & $PSScriptRoot\MultiTarget\Get-MultiTargets.ps1 -component $($componentPath.BaseName)

# If this component doesn't list one of the provided MultiTargets, skip it
if ($MultiTargets -notin $supportedMultiTargets) {
Write-Warning "Skipping $($componentPath.BaseName), no supported MultiTargets were included for build."
# Flag to check if any of the requested targets are supported by the component
$isTargetSupported = $false

foreach ($requestedTarget in $MultiTargets) {
if ($requestedTarget -in $supportedMultiTargets) {
$isTargetSupported = $true
break
}
}

# If none of the requested targets are supported by the component, we can skip build to save time and avoid errors.
if (-not $isTargetSupported) {
Write-Warning "Skipping $($componentPath.BaseName), none of the requested MultiTargets are enabled for this component."
continue
}

Invoke-MSBuildWithBinlog $componentCsproj.FullName $EnableBinLogs $BinlogOutput
}
}
}

0 comments on commit 623cb03

Please sign in to comment.