Create MSIX bundle in CI pipeline #98
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Windows Forms build and package | |
on: | |
push: | |
jobs: | |
build: | |
strategy: | |
matrix: | |
configuration: [Debug, Release] | |
runs-on: windows-latest # For a list of available runner types, refer to | |
# https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on | |
env: | |
Solution_Name: Vocup.sln # Replace with your solution name, i.e. MyWpfApp.sln. | |
App_Project_Directory: src\Vocup.WinForms | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
# Install the .NET Core workload | |
- name: Install .NET Core | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: 9.0.x | |
# Add MSBuild to the PATH: https://github.com/microsoft/setup-msbuild | |
- name: Setup MSBuild.exe | |
uses: microsoft/setup-msbuild@v2 | |
# Execute all unit tests in the solution | |
- name: Execute unit tests | |
run: dotnet test --configuration ${{ matrix.configuration }} --arch x64 | |
# Restore the application to populate the obj folder with RuntimeIdentifiers | |
- name: Restore the application | |
if: matrix.configuration == 'Release' | |
run: msbuild $env:Solution_Name /t:Restore /p:Configuration=${{ matrix.configuration }} | |
- name: Create MSIX package (x86) | |
if: matrix.configuration == 'Release' | |
run: msbuild $env:App_Project_Directory /p:Configuration=${{ matrix.configuration }} /p:Platform=x86 /p:GenerateAppxPackageOnBuild=true | |
- name: Create MSIX package (x64) | |
if: matrix.configuration == 'Release' | |
run: msbuild $env:App_Project_Directory /p:Configuration=${{ matrix.configuration }} /p:Platform=x64 /p:GenerateAppxPackageOnBuild=true | |
- name: Create MSIX package (arm64) | |
if: matrix.configuration == 'Release' | |
run: msbuild $env:App_Project_Directory /p:Configuration=${{ matrix.configuration }} /p:Platform=arm64 /p:GenerateAppxPackageOnBuild=true | |
- name: Gather MSIX files | |
id: gather | |
if: matrix.configuration == 'Release' | |
run: | | |
$gatherDirectory = Join-Path $env:App_Project_Directory "AppPackages" | |
New-Item -ItemType Directory -Path $gatherDirectory | |
$files = Get-ChildItem -Path (Join-Path $env:App_Project_Directory "bin") -Recurse -Include Vocup.WinForms*.appx,Vocup.WinForms*.appxsym | |
$files | ForEach-Object { Copy-Item -Path $_.FullName -Destination $gatherDirectory } | |
$version = $files[0].BaseName.Split("_")[1] | |
$bundleFile = Join-Path $gatherDirectory "Vocup.WinForms_$version_x86_x64_arm64.appxbundle" | |
echo "path=$gatherDirectory" >> $GITHUB_OUTPUT | |
echo "bundle_version=$version" >> $GITHUB_OUTPUT | |
echo "bundle_file=$bundleFile" >> $GITHUB_OUTPUT | |
- name: Create MSIX bundle | |
if: matrix.configuration == 'Release' | |
uses: LanceMcCarthy/[email protected] | |
with: | |
msix-folder: ${{ steps.gather.outputs.path }} | |
msixbundle-filepath: ${{ steps.gather.outputs.bundle_file }} | |
msixbundle-version: ${{ steps.gather.outputs.bundle_version }} | |
- name: Upload build artifacts | |
if: matrix.configuration == 'Release' | |
#if: matrix.configuration == 'Release' && startsWith(github.ref, 'refs/tags/') | |
uses: actions/upload-artifact@v4 | |
with: | |
name: MSIX Package | |
path: ${{ steps.gather.outputs.path }} |