Skip to content

Create MSIX upload in CI pipeline #102

Create MSIX upload in CI pipeline

Create MSIX upload in CI pipeline #102

Workflow file for this run

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
App_Project_Name: 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 "obj" "Bundle"
New-Item -ItemType Directory -Path $gatherDirectory | Out-Null
$msixFiles = Get-ChildItem -Path (Join-Path $env:App_Project_Directory "bin") -Recurse -Include $($App_Project_Name)*.appx
$msixFiles | ForEach-Object { Copy-Item -Path $_.FullName -Destination $gatherDirectory }
Write-Output "Copied $($msixFiles.Count) MSIX files to $gatherDirectory"
$version = $msixFiles[0].BaseName.Split("_")[1]
Write-Output "Bundle version based on MSIX file name is $version"
$uploadDirectory = Join-Path $env:App_Project_Directory "bin" "AppPackages"
New-Item -ItemType Directory -Path $uploadDirectory | Out-Null
$uploadFile = Join-Path $uploadDirectory "$($App_Project_Name)_$($version)_x86_x64_arm64_bundle.appxupload"
$bundleDirectory = Join-Path $uploadDirectory "$($App_Project_Name)_$($version)_Test"
New-Item -ItemType Directory -Path $bundleDirectory | Out-Null
$bundleFile = Join-Path $bundleDirectory "$($App_Project_Name)_$($version)_x86_x64_arm64.appxbundle"
$symbolFiles = Get-ChildItem -Path (Join-Path $env:App_Project_Directory "bin") -Recurse -Include $($App_Project_Name)*.appxsym
$symbolFiles | ForEach-Object { Copy-Item -Path $_.FullName -Destination $bundleDirectory }
Write-Output "Copied $($symbolFiles.Count) symbol files to $bundleDirectory"
Write-Output "gather_directory=$gatherDirectory" >> $env:GITHUB_OUTPUT
Write-Output "bundle_directory=$bundleDirectory" >> $env:GITHUB_OUTPUT
Write-Output "bundle_version=$version" >> $env:GITHUB_OUTPUT
Write-Output "bundle_file=$bundleFile" >> $env:GITHUB_OUTPUT
Write-Output "upload_directory=$uploadDirectory" >> $env:GITHUB_OUTPUT
Write-Output "upload_file=$uploadFile" >> $env:GITHUB_OUTPUT
- name: Create MSIX bundle
if: matrix.configuration == 'Release'
uses: LanceMcCarthy/Action-MsixBundler@v2.0.0
with:
msix-folder: ${{ steps.gather.outputs.gather_directory }}
msixbundle-filepath: ${{ steps.gather.outputs.bundle_file }}
msixbundle-version: ${{ steps.gather.outputs.bundle_version }}
- name: Create MSIX upload
if: matrix.configuration == 'Release'
run: |
$uploadFile = "${{ steps.gather.outputs.upload_file }}"
$bundleDirectory = "${{ steps.gather.outputs.bundle_directory }}"
Compress-Archive -Path $bundleDirectory\* -DestinationPath $uploadFile
- 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.upload_directory }}