Skip to content

Commit 8f29383

Browse files
authored
Merge pull request CommunityToolkit#350 from michael-hawker/llama/winui-package-fix
Use slngen and remove UWP target from WinUI packages
2 parents a6b7857 + 1be109f commit 8f29383

File tree

4 files changed

+132
-1034
lines changed

4 files changed

+132
-1034
lines changed

GenerateAllSolution.ps1

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
<#
2+
.SYNOPSIS
3+
Generates the solution file comprising of platform heads for samples, individual component projects, and tests.
4+
.DESCRIPTION
5+
Used mostly for CI building of everything and testing end-to-end scenarios involving the full
6+
sample app experience.
7+
8+
Otherwise it is recommended to focus on an individual component's solution instead.
9+
.PARAMETER IncludeHeads
10+
List of TFM based projects to include. This can be 'all', 'uwp', or 'winappsdk'.
11+
12+
Defaults to 'all' for local-use.
13+
.PARAMETER UseDiagnostics
14+
Add extra diagnostic output to running slngen, such as a binlog, etc...
15+
.EXAMPLE
16+
C:\PS> .\GenerateAllSolution -IncludeHeads winappsdk
17+
Build a solution that doesn't contain UWP projects.
18+
.NOTES
19+
Author: Windows Community Toolkit Labs Team
20+
Date: April 27, 2022
21+
#>
22+
Param (
23+
[Parameter(HelpMessage = "The heads to include for building platform samples and tests.", ParameterSetName = "IncludeHeads")]
24+
[ValidateSet('all', 'uwp', 'winappsdk')]
25+
[string]$IncludeHeads = 'all',
26+
27+
[Parameter(HelpMessage = "Add extra diagnostic output to slngen generator.")]
28+
[switch]$UseDiagnostics = $false
29+
)
30+
31+
# Generate required props for "All" solution.
32+
& ./common/MultiTarget/GenerateAllProjectReferences.ps1
33+
& ./common/GenerateVSCodeLaunchConfig.ps1
34+
35+
# Set up constant values
36+
$generatedSolutionFilePath = 'Toolkit.Labs.All.sln'
37+
$platforms = '"Any CPU;x64;x86;ARM64"'
38+
$slngenConfig = "--folders true --collapsefolders true --ignoreMainProject"
39+
40+
# remove previous file if it exists
41+
if (Test-Path -Path $generatedSolutionFilePath)
42+
{
43+
Remove-Item $generatedSolutionFilePath
44+
Write-Host "Removed previous solution file"
45+
}
46+
47+
# Projects to include
48+
$projects = [System.Collections.ArrayList]::new()
49+
50+
# Common/Dependencies for shared infrastructure
51+
[void]$projects.Add(".\common\**\*.*proj")
52+
53+
# Sample Apps
54+
if ($IncludeHeads -ne 'winappsdk')
55+
{
56+
[void]$projects.Add(".\platforms\**\*.Uwp.csproj")
57+
}
58+
59+
if ($IncludeHeads -ne 'uwp')
60+
{
61+
[void]$projects.Add(".\platforms\**\*.WinAppSdk.csproj")
62+
}
63+
64+
[void]$projects.Add(".\platforms\**\*.Droid.csproj")
65+
[void]$projects.Add(".\platforms\**\*.*OS.csproj")
66+
[void]$projects.Add(".\platforms\**\*.Skia.*.csproj")
67+
[void]$projects.Add(".\platforms\**\*.Wasm.csproj")
68+
69+
# Tests
70+
if ($IncludeHeads -ne 'winappsdk')
71+
{
72+
[void]$projects.Add(".\tests\**\*.Uwp.csproj")
73+
}
74+
75+
if ($IncludeHeads -ne 'uwp')
76+
{
77+
[void]$projects.Add(".\tests\**\*.WinAppSdk.csproj")
78+
}
79+
80+
# Individual projects
81+
[void]$projects.Add(".\labs\**\src\*.csproj")
82+
[void]$projects.Add(".\labs\**\samples\*.Samples\*.Samples.csproj")
83+
[void]$projects.Add(".\labs\**\tests\*.Tests\*.shproj")
84+
85+
if ($UseDiagnostics.IsPresent)
86+
{
87+
$sdkoptions = " -d"
88+
$diagnostics = '-bl:slngen.binlog --consolelogger:"ShowEventId;Summary;Verbosity=Detailed" --filelogger:"LogFile=slngen.log;Append;Verbosity=Diagnostic;Encoding=UTF-8" '
89+
}
90+
else
91+
{
92+
$sdkoptions = ""
93+
$diagnostics = ""
94+
}
95+
96+
$cmd = "dotnet$sdkoptions tool run slngen -o $generatedSolutionFilePath $slngenConfig $diagnostics--platform $platforms $($projects -Join ' ')"
97+
98+
Write-Output "Running Command: $cmd"
99+
100+
Invoke-Expression $cmd

Labs.Head.props

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@
3030
<IsProjectTemplateHead Condition="$(MSBuildProjectName.StartsWith('ProjectTemplate')) == 'true'">true</IsProjectTemplateHead>
3131
<IsSingleExperimentHead Condition="'$(IsAllExperimentHead)' != 'true' AND '$(IsProjectTemplateHead)' != 'true'">true</IsSingleExperimentHead>
3232

33-
<DefineConstants Condition="$(IsAllExperimentHead) == 'true'">$(DefineConstants);LABS_ALL_SAMPLES</DefineConstants>
33+
<DefineConstants Condition="$(IsAllExperimentHead) == 'true'">$(DefineConstants);LABS_ALL_SAMPLES</DefineConstants>
34+
35+
<SlnGenIsDeployable>true</SlnGenIsDeployable>
3436
</PropertyGroup>
3537

3638
<!-- See https://github.com/CommunityToolkit/Labs-Windows/issues/142 -->

Scripts/UseTargetFrameworks.ps1

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,30 @@
1+
<#
2+
.SYNOPSIS
3+
Changes the target frameworks to build for each package created within the repository.
4+
.DESCRIPTION
5+
By default, only the UWP, Windows App SDK, and WASM heads are built to simplify dependencies
6+
needed to build projects within the repository. The CI will enable all targets to build a package
7+
that works on all supported platforms.
8+
9+
Note: Projects which rely on target platforms that are excluded will be unable to build.
10+
.PARAMETER targets
11+
List of targets to set as TFM platforms to build for. This can also be 'all', 'all-uwp', or blank.
12+
When run as blank, teh defaults (uwp, winappsdk, wasm) will be used.
13+
'all' and 'all-uwp' shouldn't be used with other targets or each other.
14+
.PARAMETER allowGitChanges
15+
Enabling this flag will allow changes to the props file to be checked into source control.
16+
By default the file is ignored so local changes to building don't accidently get checked in.
17+
.EXAMPLE
18+
C:\PS> .\UseTargetFrameworks winappsdk
19+
Build targets for just the WindowsAppSDK.
20+
.NOTES
21+
Author: Windows Community Toolkit Labs Team
22+
Date: April 8, 2022
23+
#>
124
Param (
225
[Parameter(HelpMessage = "The target frameworks to enable.")]
3-
[ValidateSet('all', 'wasm', 'uwp', 'winappsdk', 'wpf', 'gtk', 'macos', 'ios', 'droid')]
4-
[string[]]$targets = @('uwp', 'winappsdk', 'wasm'),
26+
[ValidateSet('all', 'all-uwp', 'wasm', 'uwp', 'winappsdk', 'wpf', 'gtk', 'macos', 'ios', 'droid')]
27+
[string[]]$targets = @('uwp', 'winappsdk', 'wasm'), # default settings
528

629
[Parameter(HelpMessage = "Disables suppressing changes to the Labs.TargetFrameworks.props file in git, allowing changes to be committed.")]
730
[switch]$allowGitChanges = $false
@@ -47,6 +70,10 @@ if ($targets.Contains("all")) {
4770
$desiredTfmValues = $allTargetFrameworks;
4871
}
4972

73+
if ($targets.Contains("all-uwp")) {
74+
$desiredTfmValues = $allTargetFrameworks.Replace($UwpTfm, "");
75+
}
76+
5077
if ($targets.Contains("wasm")) {
5178
$desiredTfmValues += $WasmTfm;
5279
}

0 commit comments

Comments
 (0)