Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions .github/workflows/dotnet-desktop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: .NET Core Desktop CI/CD

on:
push:
branches: [ "main" ]

jobs:
build:
strategy:
matrix:
configuration: [Debug, Release]

runs-on: windows-latest

env:
Solution_Name: MyApp.sln
Test_Project_Path: MyApp.Tests/MyApp.Tests.csproj
Wap_Project_Directory: MyApp.Package
Wap_Project_Path: MyApp.Package/MyApp.Package.wapproj

steps:
- name: Checkout source
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install .NET 8 SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x

- name: Setup MSBuild
uses: microsoft/setup-msbuild@v2

- name: Run unit tests
run: dotnet test $env:Test_Project_Path

- name: Restore solution
run: msbuild $env:Solution_Name /t:Restore /p:Configuration=$env:Configuration
env:
Configuration: ${{ matrix.configuration }}

- name: Decode signing certificate
run: |
$pfx_cert_byte = [System.Convert]::FromBase64String("${{ secrets.Base64_Encoded_Pfx }}")
Copy link

Copilot AI Jan 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The certificate file is created but there's no error handling if the Base64_Encoded_Pfx secret is missing or invalid. If the secret is not set, this step will fail silently or create an invalid certificate file, leading to confusing build failures in subsequent steps. Consider adding validation or using the 'if' conditional to check if secrets are available.

Suggested change
$pfx_cert_byte = [System.Convert]::FromBase64String("${{ secrets.Base64_Encoded_Pfx }}")
if (-not "${{ secrets.Base64_Encoded_Pfx }}") {
Write-Error "The 'Base64_Encoded_Pfx' secret is not set or is empty. Please configure this secret in the repository settings."
exit 1
}
try {
$pfx_cert_byte = [System.Convert]::FromBase64String("${{ secrets.Base64_Encoded_Pfx }}")
}
catch {
Write-Error "Failed to decode 'Base64_Encoded_Pfx' secret. Ensure it contains a valid Base64-encoded PFX certificate."
exit 1
}

Copilot uses AI. Check for mistakes.
$certificatePath = Join-Path -Path $env:Wap_Project_Directory -ChildPath GitHubActionsWorkflow.pfx
[IO.File]::WriteAllBytes("$certificatePath", $pfx_cert_byte)

- name: Build and package MSIX
env:
PFX_PASSWORD: ${{ secrets.Pfx_Key }}
run: msbuild $env:Wap_Project_Path /p:Configuration=$env:Configuration /p:UapAppxPackageBuildMode=$env:Appx_Package_Build_Mode /p:AppxBundle=$env:Appx_Bundle /p:PackageCertificateKeyFile=GitHubActionsWorkflow.pfx /p:PackageCertificatePassword="$env:PFX_PASSWORD"
env:
Appx_Bundle: Always
Appx_Bundle_Platforms: x86|x64
Appx_Package_Build_Mode: StoreUpload
Configuration: ${{ matrix.configuration }}

- name: Remove temporary certificate
if: always()
run: Remove-Item -path $env:Wap_Project_Directory\GitHubActionsWorkflow.pfx
Copy link

Copilot AI Jan 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The certificate cleanup step uses a hardcoded backslash path separator which works on Windows but is inconsistent with the forward slash used in line 46. While both work on Windows, consider using consistent path separators throughout the workflow or using PowerShell's Join-Path for platform independence.

Suggested change
run: Remove-Item -path $env:Wap_Project_Directory\GitHubActionsWorkflow.pfx
run: |
$certificatePath = Join-Path -Path $env:Wap_Project_Directory -ChildPath GitHubActionsWorkflow.pfx
Remove-Item -Path $certificatePath

Copilot uses AI. Check for mistakes.

- name: Upload MSIX artifacts
uses: actions/upload-artifact@v4
with:
name: MSIX-Package
path: ${{ env.Wap_Project_Directory }}\bin\${{ matrix.configuration }}
Copy link

Copilot AI Jan 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The artifact upload path uses backslash separators and may not work correctly if the directory structure changes. Consider using forward slashes or the format '${{ env.Wap_Project_Directory }}/bin/${{ matrix.configuration }}' for better cross-platform compatibility and consistency with GitHub Actions conventions.

Suggested change
path: ${{ env.Wap_Project_Directory }}\bin\${{ matrix.configuration }}
path: ${{ env.Wap_Project_Directory }}/bin/${{ matrix.configuration }}

Copilot uses AI. Check for mistakes.