Skip to content

Commit 64e945b

Browse files
committed
Only include heads for requested MultiTargets if Components that use them were included
1 parent 660f1b8 commit 64e945b

File tree

1 file changed

+28
-20
lines changed

1 file changed

+28
-20
lines changed

GenerateAllSolution.ps1

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -111,28 +111,14 @@ $projects = [System.Collections.ArrayList]::new()
111111
# Common/Dependencies for shared infrastructure
112112
[void]$projects.Add(".\tooling\CommunityToolkit*\*.*proj")
113113

114-
# Deployable sample gallery heads
115-
# TODO: this handles separate project heads, but won't directly handle the unified Skia head from Uno.
116-
# Once we have that, just do a transform on the csproj filename inside this loop to decide the same csproj for those separate MultiTargets.
117-
foreach ($multitarget in $MultiTargets) {
118-
# capitalize first letter, avoid case sensitivity issues on linux
119-
$csprojFileNamePartForMultiTarget = $multitarget.substring(0,1).ToUpper() + $multitarget.Substring(1).ToLower()
120-
121-
$path = ".\tooling\ProjectHeads\AllComponents\**\*.$csprojFileNamePartForMultiTarget.csproj";
122-
123-
if (Test-Path $path) {
124-
[void]$projects.Add($path)
125-
}
126-
else {
127-
Write-Warning "No project head could be found at $path for MultiTarget $multitarget. Skipping."
128-
}
129-
}
130-
131114
# Individual projects
132115
if ($Components -eq @('all')) {
133116
$Components = @('**')
134117
}
135118

119+
120+
$allUsedMultiTargetPrefs = @()
121+
136122
foreach ($componentName in $Components) {
137123
if ($ExcludeComponents -contains $componentName) {
138124
continue;
@@ -141,11 +127,13 @@ foreach ($componentName in $Components) {
141127
foreach ($componentPath in Get-Item "$PSScriptRoot/../components/$componentName/") {
142128
$multiTargetPrefs = & $PSScriptRoot\MultiTarget\Get-MultiTargets.ps1 -component $($componentPath.BaseName)
143129

144-
$shouldReferenceInSolution = $multiTargetPrefs.Where({ $MultiTargets.Contains($_) }).Count -gt 0
145-
130+
$usedMultiTargetPrefs = $multiTargetPrefs.Where({ $MultiTargets.Contains($_) });
131+
$shouldReferenceInSolution = $usedMultiTargetPrefs.Count -gt 0
132+
146133
if ($shouldReferenceInSolution) {
147134
Write-Output "Add component $componentPath to solution";
148-
135+
$allUsedMultiTargetPrefs += $usedMultiTargetPrefs
136+
149137
[void]$projects.Add(".\components\$($componentPath.BaseName)\src\*.csproj")
150138
[void]$projects.Add(".\components\$($componentPath.BaseName)\samples\*.Samples.csproj")
151139
[void]$projects.Add(".\components\$($componentPath.BaseName)\tests\*.shproj")
@@ -155,6 +143,26 @@ foreach ($componentName in $Components) {
155143
}
156144
}
157145

146+
# Deployable sample gallery heads
147+
# Only include heads for requested MultiTargets if components were included that use them.
148+
# ===
149+
# TODO: this handles separate project heads, but won't directly handle the unified Skia head from Uno.
150+
# Once we have that, just do a transform on the csproj filename inside this loop to decide the same csproj for those separate MultiTargets.
151+
# ===
152+
foreach ($multitarget in $allUsedMultiTargetPrefs) {
153+
# capitalize first letter, avoid case sensitivity issues on linux
154+
$csprojFileNamePartForMultiTarget = $multitarget.substring(0,1).ToUpper() + $multitarget.Substring(1).ToLower()
155+
156+
$path = ".\tooling\ProjectHeads\AllComponents\**\*.$csprojFileNamePartForMultiTarget.csproj";
157+
158+
if (Test-Path $path) {
159+
[void]$projects.Add($path)
160+
}
161+
else {
162+
Write-Warning "No project head could be found at $path for MultiTarget $multitarget. Skipping."
163+
}
164+
}
165+
158166
if ($UseDiagnostics.IsPresent)
159167
{
160168
$sdkoptions = "-d"

0 commit comments

Comments
 (0)