From a02f23075ca47e931a8af3b69e71832101d45ae5 Mon Sep 17 00:00:00 2001 From: michael-hawker <24302614+michael-hawker@users.noreply.github.com> Date: Mon, 9 Jan 2023 13:48:00 -0800 Subject: [PATCH] Potential Fix for #262 - Remove UWP target from WinUI packages 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 --- .github/workflows/build.yml | 12 ++++++---- common/Scripts/UseTargetFrameworks.ps1 | 31 ++++++++++++++++++++++++-- 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a59ae2aed..d87c3f15f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 @@ -72,9 +76,9 @@ jobs: - name: Add msbuild to PATH uses: microsoft/setup-msbuild@v1.0.3 - - 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 @@ -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 diff --git a/common/Scripts/UseTargetFrameworks.ps1 b/common/Scripts/UseTargetFrameworks.ps1 index f6f811489..0510b15d1 100644 --- a/common/Scripts/UseTargetFrameworks.ps1 +++ b/common/Scripts/UseTargetFrameworks.ps1 @@ -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 @@ -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; }