Skip to content

Commit 478d327

Browse files
committed
Refactor dotnet-desktop.yml to improve variable usage and streamline build steps
1 parent 80f3cf5 commit 478d327

1 file changed

Lines changed: 30 additions & 24 deletions

File tree

.github/workflows/dotnet-desktop.yml

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ jobs:
1818
Solution_Name: TTSBroswer.sln
1919
Test_Project_Path: TTSBroswer.TTSBroswer/TTSBroswer.TTSBroswer.csproj
2020
Wap_Project_Directory: TTSBroswer.TSBroswer
21-
Wap_Project_Path: TTSBroswer.TTSBroswer/TTSBroswer.TTSBroswer.wapproj
21+
Wap_Project_Path: TTSBroswer.TSBroswer/TTSBroswer.TSBroswer.wapproj
22+
BASE64_PFX: ${{ secrets.Base64_Encoded_Pfx }}
2223

2324
steps:
2425
- name: Checkout repository
@@ -35,39 +36,44 @@ jobs:
3536
uses: microsoft/setup-msbuild@v2
3637

3738
- name: Restore NuGet packages
38-
run: dotnet restore $env:Solution_Name
39+
run: dotnet restore ${{ env.Solution_Name }}
3940

4041
- name: Build solution
41-
run: msbuild $env:Solution_Name /p:Configuration=$env:Configuration
42-
env:
43-
Configuration: ${{ matrix.configuration }}
42+
run: msbuild ${{ env.Solution_Name }} /p:Configuration=${{ matrix.configuration }}
4443

4544
- name: Execute unit tests
46-
run: dotnet test $env:Test_Project_Path --configuration $env:Configuration --no-build --verbosity normal
47-
48-
- name: Restore Wap project
49-
run: msbuild $env:Wap_Project_Path /t:Restore /p:Configuration=$env:Configuration
50-
env:
51-
Configuration: ${{ matrix.configuration }}
45+
run: dotnet test ${{ env.Test_Project_Path }} --configuration ${{ matrix.configuration }} --no-build --verbosity normal
5246

47+
- name: Restore WAP project
48+
run: |
49+
msbuild "${{ env.Wap_Project_Path }}" /t:Restore /p:Configuration=${{ matrix.configuration }}
5350
- name: Decode the pfx
54-
if: ${{ secrets.Base64_Encoded_Pfx != '' }}
51+
if: env.BASE64_PFX != ''
52+
shell: pwsh
5553
run: |
56-
$pfx_cert_byte = [System.Convert]::FromBase64String("${{ secrets.Base64_Encoded_Pfx }}")
57-
$certificatePath = Join-Path -Path $env:Wap_Project_Directory -ChildPath GitHubActionsWorkflow.pfx
58-
[IO.File]::WriteAllBytes("$certificatePath", $pfx_cert_byte)
54+
$pfx_cert_byte = [System.Convert]::FromBase64String("${{ env.BASE64_PFX }}")
55+
$certificatePath = Join-Path -Path "${{ env.Wap_Project_Directory }}" -ChildPath "GitHubActionsWorkflow.pfx"
56+
[System.IO.File]::WriteAllBytes($certificatePath, $pfx_cert_byte)
57+
[System.IO.File]::WriteAllBytes($certificatePath, $pfx_cert_byte)
5958
6059
- name: Create the app package
61-
run: msbuild $env:Wap_Project_Path /p:Configuration=$env:Configuration /p:UapAppxPackageBuildMode=$env:Appx_Package_Build_Mode /p:AppxBundle=$env:Appx_Bundle /p:AppxBundlePlatforms=$env:Appx_Bundle_Platforms /p:PackageCertificateKeyFile=$env:Wap_Project_Directory\GitHubActionsWorkflow.pfx /p:PackageCertificatePassword=${{ secrets.Pfx_Key }}
62-
env:
63-
Appx_Bundle: Always
64-
Appx_Bundle_Platforms: x86|x64
65-
Appx_Package_Build_Mode: StoreUpload
66-
Configuration: ${{ matrix.configuration }}
67-
60+
run: |
61+
msbuild "${{ env.Wap_Project_Path }}" `
62+
/p:Configuration=${{ matrix.configuration }} `
63+
/p:UapAppxPackageBuildMode=StoreUpload `
64+
/p:AppxBundle=Always `
65+
/p:AppxBundlePlatforms="x86|x64" `
66+
/p:PackageCertificateKeyFile="${{ env.Wap_Project_Directory }}\GitHubActionsWorkflow.pfx" `
67+
/p:PackageCertificatePassword=${{ secrets.Pfx_Key }}
6868
- name: Remove the pfx
69-
if: ${{ secrets.Base64_Encoded_Pfx != '' }}
70-
run: Remove-Item -Path "$env:Wap_Project_Directory\GitHubActionsWorkflow.pfx" -Force
69+
if: env.BASE64_PFX != ''
70+
shell: pwsh
71+
run: |
72+
$certificatePath = Join-Path -Path "${{ env.Wap_Project_Directory }}" -ChildPath "GitHubActionsWorkflow.pfx"
73+
if (Test-Path $certificatePath) {
74+
Remove-Item -Path $certificatePath -Force
75+
}
76+
}
7177
7278
- name: Upload build artifacts
7379
uses: actions/upload-artifact@v4

0 commit comments

Comments
 (0)