Skip to content

Fix GitHub Actions workflows for UWP MSIX builds #3

Fix GitHub Actions workflows for UWP MSIX builds

Fix GitHub Actions workflows for UWP MSIX builds #3

# This workflow builds and packages the UWP application as MSIX

Check failure on line 1 in .github/workflows/dotnet-desktop.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/dotnet-desktop.yml

Invalid workflow file

(Line: 41, Col: 11): Unrecognized named-value: 'secrets'. Located at position 2 within expression: !secrets.Base64_Encoded_Pfx, (Line: 48, Col: 11): Unrecognized named-value: 'secrets'. Located at position 1 within expression: secrets.Base64_Encoded_Pfx, (Line: 55, Col: 11): Unrecognized named-value: 'secrets'. Located at position 1 within expression: secrets.Base64_Encoded_Pfx, (Line: 59, Col: 11): Unrecognized named-value: 'secrets'. Located at position 2 within expression: !secrets.Base64_Encoded_Pfx, (Line: 63, Col: 11): Unrecognized named-value: 'secrets'. Located at position 1 within expression: secrets.Base64_Encoded_Pfx
# For signing with a certificate, add Base64_Encoded_Pfx and Pfx_Key secrets to the repository
name: Build UWP MSIX
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
jobs:
build:
strategy:
matrix:
configuration: [Release]
platform: [x64]
runs-on: windows-latest
env:
Solution_Name: eComBox.sln
Project_Path: eComBox.csproj
AppxPackageDir: AppPackages\
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup MSBuild
uses: microsoft/setup-msbuild@v2
- name: Restore NuGet packages
run: nuget restore $env:Solution_Name
- name: Generate self-signed certificate (if secrets not available)
if: ${{ !secrets.Base64_Encoded_Pfx }}
run: |
New-SelfSignedCertificate -Type Custom -Subject "CN=eComBox Test Certificate" -KeyUsage DigitalSignature -FriendlyName "eComBox Test Cert" -CertStoreLocation "Cert:\CurrentUser\My" -TextExtension @("2.5.29.37={text}1.3.6.1.5.5.7.3.3", "2.5.29.19={text}")
$thumbprint = (Get-ChildItem -Path Cert:\CurrentUser\My | Where-Object {$_.Subject -match "eComBox Test Certificate"} | Select-Object -First 1).Thumbprint
Write-Host "Certificate thumbprint: $thumbprint"
- name: Decode the pfx (if secret available)
if: ${{ secrets.Base64_Encoded_Pfx }}
run: |
$pfx_cert_byte = [System.Convert]::FromBase64String("${{ secrets.Base64_Encoded_Pfx }}")
$certificatePath = "GitHubActionsWorkflow.pfx"
[IO.File]::WriteAllBytes("$certificatePath", $pfx_cert_byte)
- name: Build MSIX package (with certificate)
if: ${{ secrets.Base64_Encoded_Pfx }}
run: msbuild $env:Solution_Name /p:Configuration=${{ matrix.configuration }} /p:Platform=${{ matrix.platform }} /p:UapAppxPackageBuildMode=SideloadOnly /p:AppxBundle=Never /p:AppxPackageDir=$env:AppxPackageDir /p:PackageCertificateKeyFile=GitHubActionsWorkflow.pfx /p:PackageCertificatePassword=${{ secrets.Pfx_Key }} /p:AppxPackageSigningEnabled=true
- name: Build MSIX package (without signing)
if: ${{ !secrets.Base64_Encoded_Pfx }}
run: msbuild $env:Solution_Name /p:Configuration=${{ matrix.configuration }} /p:Platform=${{ matrix.platform }} /p:UapAppxPackageBuildMode=SideloadOnly /p:AppxBundle=Never /p:AppxPackageDir=$env:AppxPackageDir /p:AppxPackageSigningEnabled=false
- name: Remove the pfx
if: ${{ secrets.Base64_Encoded_Pfx }}
run: Remove-Item -path GitHubActionsWorkflow.pfx -ErrorAction SilentlyContinue
- name: Upload MSIX package
uses: actions/upload-artifact@v4
with:
name: MSIX-Package-${{ matrix.platform }}-${{ matrix.configuration }}
path: ${{ env.AppxPackageDir }}**/*.msix