Skip to content

Commit

Permalink
Potential Fix for #262 - Remove UWP target from WinUI packages
Browse files Browse the repository at this point in the history
Adds a 'all-uwp' target to UseTargetFrameworks.ps1
Adds better documentation to UseTargetFrameworks.ps1
Conditionally selects the set of platforms to build for in the CI based on if running the UWP or WinUI package job
  • Loading branch information
michael-hawker committed Jan 9, 2023
1 parent b2b9f85 commit a02f230
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 6 deletions.
12 changes: 8 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ jobs:
matrix:
platform: [WinUI2, WinUI3]

env:
# faux-ternary expression to select which platforms to build for each platform vs. duplicating step below.
TARGET_PLATFORMS: ${{ matrix.platform != 'WinUI' && 'all' || 'all-uwp' }}

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Install .NET 6 SDK
Expand All @@ -72,9 +76,9 @@ jobs:
- name: Add msbuild to PATH
uses: microsoft/[email protected]

- name: Enable all TargetFrameworks
- name: Enable ${{ env.TARGET_PLATFORMS }} TargetFrameworks
working-directory: ./common/Scripts/
run: powershell -version 5.1 -command "./UseTargetFrameworks.ps1 all" -ErrorAction Stop
run: powershell -version 5.1 -command "./UseTargetFrameworks.ps1 ${{ env.TARGET_PLATFORMS }}" -ErrorAction Stop

- name: Generate solution
run: powershell -version 5.1 -command "./GenerateAllSolution.ps1" -ErrorAction Stop
Expand All @@ -94,11 +98,11 @@ jobs:

# Push Packages to our DevOps Artifacts Feed
- name: Add source
if: ${{github.ref == 'refs/heads/main'}}
if: ${{ github.ref == 'refs/heads/main' }}
run: dotnet nuget add source "https://pkgs.dev.azure.com/dotnet/CommunityToolkit/_packaging/CommunityToolkit-Labs/nuget/v3/index.json" --name LabsFeed --username dummy --password ${{ secrets.DEVOPS_PACKAGE_PUSH_TOKEN }}

- name: Push packages
if: ${{github.ref == 'refs/heads/main'}}
if: ${{ github.ref == 'refs/heads/main' }}
run: dotnet nuget push "**/*.nupkg" --api-key dummy --source LabsFeed --skip-duplicate

# Run tests
Expand Down
31 changes: 29 additions & 2 deletions common/Scripts/UseTargetFrameworks.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,30 @@
<#
.SYNOPSIS
Changes the target frameworks to build for each package created within the repository.
.DESCRIPTION
By default, only the UWP, Windows App SDK, and WASM heads are built to simplify dependencies
needed to build projects within the repository. The CI will enable all targets to build a package
that works on all supported platforms.
Note: Projects which rely on target platforms that are excluded will be unable to build.
.PARAMETER targets
List of targets to set as TFM platforms to build for. This can also be 'all', 'all-uwp', or blank.
When run as blank, teh defaults (uwp, winappsdk, wasm) will be used.
'all' and 'all-uwp' shouldn't be used with other targets or each other.
.PARAMETER allowGitChanges
Enabling this flag will allow changes to the props file to be checked into source control.
By default the file is ignored so local changes to building don't accidently get checked in.
.EXAMPLE
C:\PS> .\UseTargetFrameworks winappsdk
Build targets for just the WindowsAppSDK.
.NOTES
Author: Windows Community Toolkit Labs Team
Date: April 8, 2022
#>
Param (
[Parameter(HelpMessage = "The target frameworks to enable.")]
[ValidateSet('all', 'wasm', 'uwp', 'winappsdk', 'wpf', 'gtk', 'macos', 'ios', 'droid')]
[string[]]$targets = @('uwp', 'winappsdk', 'wasm'),
[ValidateSet('all', 'all-uwp', 'wasm', 'uwp', 'winappsdk', 'wpf', 'gtk', 'macos', 'ios', 'droid')]
[string[]]$targets = @('uwp', 'winappsdk', 'wasm'), # default settings

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

if ($targets.Contains("all-uwp")) {
$desiredTfmValues = $allTargetFrameworks.Replace($UwpTfm, "");
}

if ($targets.Contains("wasm")) {
$desiredTfmValues += $WasmTfm;
}
Expand Down

0 comments on commit a02f230

Please sign in to comment.