Skip to content

Commit e7a8fd2

Browse files
authored
Modify .NET Core Desktop workflow for .NET 9
Updated the GitHub Actions workflow for .NET 9, changing the name and adjusting build steps.
1 parent 1638ed2 commit e7a8fd2

File tree

1 file changed

+36
-65
lines changed

1 file changed

+36
-65
lines changed

.github/workflows/dotnet-desktop.yml

Lines changed: 36 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -36,80 +36,51 @@
3636
# For a complete CI/CD sample to get started with GitHub Action workflows for Desktop Applications,
3737
# refer to https://github.com/microsoft/github-actions-for-desktop-apps
3838

39-
name: .NET Core Desktop
39+
name: .NET 9 build & run
4040

4141
on:
4242
push:
43-
branches: [ "main" ]
44-
pull_request:
45-
branches: [ "main" ]
43+
branches: [ main ]
44+
workflow_dispatch:
4645

4746
jobs:
48-
4947
build:
50-
51-
strategy:
52-
matrix:
53-
configuration: [Debug, Release]
54-
55-
runs-on: windows-latest # For a list of available runner types, refer to
56-
# https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on
57-
58-
env:
59-
Solution_Name: your-solution-name # Replace with your solution name, i.e. MyWpfApp.sln.
60-
Test_Project_Path: your-test-project-path # Replace with the path to your test project, i.e. MyWpfApp.Tests\MyWpfApp.Tests.csproj.
61-
Wap_Project_Directory: your-wap-project-directory-name # Replace with the Wap project directory relative to the solution, i.e. MyWpfApp.Package.
62-
Wap_Project_Path: your-wap-project-path # Replace with the path to your Wap project, i.e. MyWpf.App.Package\MyWpfApp.Package.wapproj.
63-
48+
runs-on: ubuntu-latest
6449
steps:
65-
- name: Checkout
66-
uses: actions/checkout@v4
67-
with:
68-
fetch-depth: 0
50+
- uses: actions/checkout@v4
6951

70-
# Install the .NET Core workload
71-
- name: Install .NET Core
72-
uses: actions/setup-dotnet@v4
73-
with:
74-
dotnet-version: 8.0.x
52+
- name: Setup .NET 9 SDK
53+
uses: actions/setup-dotnet@v4
54+
with:
55+
dotnet-version: '9.0.x'
7556

76-
# Add MSBuild to the PATH: https://github.com/microsoft/setup-msbuild
77-
- name: Setup MSBuild.exe
78-
uses: microsoft/setup-msbuild@v2
57+
- name: Restore
58+
run: dotnet restore ./LibrarySystem.csproj
7959

80-
# Execute all unit tests in the solution
81-
- name: Execute unit tests
82-
run: dotnet test
60+
- name: Build (Release)
61+
run: dotnet build ./LibrarySystem.csproj -c Release --no-restore
8362

84-
# Restore the application to populate the obj folder with RuntimeIdentifiers
85-
- name: Restore the application
86-
run: msbuild $env:Solution_Name /t:Restore /p:Configuration=$env:Configuration
87-
env:
88-
Configuration: ${{ matrix.configuration }}
89-
90-
# Decode the base 64 encoded pfx and save the Signing_Certificate
91-
- name: Decode the pfx
92-
run: |
93-
$pfx_cert_byte = [System.Convert]::FromBase64String("${{ secrets.Base64_Encoded_Pfx }}")
94-
$certificatePath = Join-Path -Path $env:Wap_Project_Directory -ChildPath GitHubActionsWorkflow.pfx
95-
[IO.File]::WriteAllBytes("$certificatePath", $pfx_cert_byte)
96-
97-
# Create the app package by building and packaging the Windows Application Packaging project
98-
- name: Create the app package
99-
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=${{ secrets.Pfx_Key }}
100-
env:
101-
Appx_Bundle: Always
102-
Appx_Bundle_Platforms: x86|x64
103-
Appx_Package_Build_Mode: StoreUpload
104-
Configuration: ${{ matrix.configuration }}
105-
106-
# Remove the pfx
107-
- name: Remove the pfx
108-
run: Remove-Item -path $env:Wap_Project_Directory\GitHubActionsWorkflow.pfx
63+
run-demo:
64+
needs: build
65+
runs-on: ubuntu-latest
66+
steps:
67+
- uses: actions/checkout@v4
68+
- uses: actions/setup-dotnet@v4
69+
with:
70+
dotnet-version: '9.0.x'
71+
72+
- name: Build
73+
run: dotnet build ./LibrarySystem.csproj -c Release
74+
75+
# 你個程式係互動式;用 printf 餵輸入(按你 Program.cs 菜單改)
76+
- name: Run with scripted input
77+
shell: bash
78+
run: |
79+
printf "3\n" | dotnet run --project ./LibrarySystem.csproj -c Release --no-build | tee run.log
80+
81+
- name: Upload console output
82+
uses: actions/upload-artifact@v4
83+
with:
84+
name: console-output
85+
path: run.log
10986

110-
# Upload the MSIX package: https://github.com/marketplace/actions/upload-a-build-artifact
111-
- name: Upload build artifacts
112-
uses: actions/upload-artifact@v4
113-
with:
114-
name: MSIX Package
115-
path: ${{ env.Wap_Project_Directory }}\AppPackages

0 commit comments

Comments
 (0)