From 2ac9c51b545f361a3976809ec127c67f145cfb15 Mon Sep 17 00:00:00 2001 From: Edward Skrod Date: Mon, 6 Apr 2020 10:12:17 -0400 Subject: [PATCH 1/6] Added starter workflow for desktop apps. --- ci/desktop.yml | 109 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 ci/desktop.yml diff --git a/ci/desktop.yml b/ci/desktop.yml new file mode 100644 index 0000000..83ff99a --- /dev/null +++ b/ci/desktop.yml @@ -0,0 +1,109 @@ +# This workflow will build, test and create app packages for a Wpf project built on Net Core. +# +# To configure this workflow: +# +# 1. Configure environment variables +# GitHub sets default environment variables for every workflow run. Replace the variables relative to your +# project in the "env" section below. +# +# 2. Signing +# Generate a signing certificate in the Windows Application Packaging Project or add an existing signing certificate +# to the project. Next, use PowerShell to encode the .pfx file using Base64 encoding by running the following Powershell +# script to generate the output file. +# +# $pfx_cert = Get-Content '.\SigningCertificate.pfx' -Encoding Byte +# [System.Convert]::ToBase64String($pfx_cert) | Out-File 'SigningCertificate_Encoded.txt' +# +# Open the output file, SigningCertificate_Encoded.txt, and copy the string inside. Then, add the string to the repo +# as a GitHub secret and name it "Base64_Encoded_Pfx." +# For more information on how to configure your signing certificate for this workflow, refer +# to https://github.com/microsoft/github-actions-for-desktop-apps#signing +# +# Finally, add the signing certificate password to the repo as a secret and name it "Pfx_Key." +# See "Build the Windows Application Packaging project" below to see how the secret is used. +# +# For more information on GitHub Actions, refer to https://github.com/features/actions +# For a complete CI/CD sample to get started with GitHub Action workflows for Desktop Applications, +# refer to https://github.com/microsoft/github-actions-for-desktop-apps + +name: Build and publish a desktop application + +# Trigger on every master branch push and pull request +on: + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + + build: + + strategy: + matrix: + configuration: [Debug, Release] + + runs-on: windows-latest + + env: + Appx_Bundle: Always # Creates an .msixbundle/.appxbundle with the .msix/.appx files for the platform specified. + App_Packages_Directory: AppPackages # The name of the directory that will contain the application packages. The default is "AppPackages." + Appx_Bundle_Platforms: x86|x64 # Include x86 and x64 platforms in the bundle. Possible values: x86|x64|ARM + Appx_Package_Build_Mode: StoreUpload # Generates the .msixupload/.appxupload file and the _Test folder for sideloading. + Signing_Certificate: GitHubActionsDemo.pfx # The name of the .pfx that will be created by decoding the Base 64 secret and consumed during the packaging step. + Solution_Name: your-solution-name # Replace with your solution name, i.e. MyWpfApp.sln. + Test_Project_Path: your-test-project-path # Replace with the path to your test project, i.e. MyWpfApp.Tests\MyWpfApp.Tests.csproj. + Wap_Project_Directory: your-wap-project-directory-name # Replace with the Wap project directory relative to the solution, i.e. MyWpfApp.Package. + Wap_Project_Path: your-wap-project-path # Replace with the path to your Wap project, i.e. MyWpf.App.Package\MyWpfApp.Package.wapproj. + + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + # Install the .NET Core workload + - name: Install .NET Core + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 3.1.100 + + # Add MsBuild to the PATH: https://github.com/microsoft/setup-msbuild + - name: Setup MSBuild.exe + uses: microsoft/setup-msbuild@v1.0.0 + + # Test + - name: Execute Unit Tests + run: dotnet test $env:Test_Project_Path + + # Restore the Wpf application to populate the obj folder with RuntimeIdentifiers + - name: Restore the Wpf application + run: msbuild $env:Solution_Name /t:Restore /p:Configuration=$env:Configuration + env: + Configuration: ${{ matrix.configuration }} + + # Decode the Base64 encoded Pfx + - name: Decode the Pfx + run: | + $pfx_cert_byte = [System.Convert]::FromBase64String("${{ secrets.Base64_Encoded_Pfx }}") + $certificatePath = Join-Path -Path $env:Wap_Project_Directory -ChildPath $env:Signing_Certificate + [IO.File]::WriteAllBytes("$certificatePath", $pfx_cert_byte) + + # Create the app package by building and packaging the Windows Application Packaging project + - name: Create the App Package + run: msbuild $env:Wap_Project_Path /p:Configuration=$env:Configuration /p:UapAppxPackageBuildMode=$env:Appx_Package_Build_Mode /p:AppxBundle=$env:Appx_Bundle /p:PackageCertificateKeyFile=$env:Signing_Certificate /p:PackageCertificatePassword=${{ secrets.Pfx_Key }} + env: + Configuration: ${{ matrix.configuration }} + + # Remove the .pfx + - name: Remove the .pfx + run: Remove-Item -path $env:Wap_Project_Directory\$env:Signing_Certificate + + # Upload the MSIX package: https://github.com/marketplace/actions/upload-artifact + - name: Upload build artifacts + uses: actions/upload-artifact@v1 + with: + name: MSIX Package + path: ${{ env.Wap_Project_Directory }}\${{ env.App_Packages_Directory }} From 0c7710ef26500dbfaa7a5bd2e8028b765130b2b6 Mon Sep 17 00:00:00 2001 From: Edward Skrod Date: Mon, 6 Apr 2020 10:29:23 -0400 Subject: [PATCH 2/6] Added the properties file and updated the workflow file to conform to PR specifications. --- ci/desktop.yml | 27 +++++++++++++-------------- ci/properties/desktop.properties.json | 6 ++++++ 2 files changed, 19 insertions(+), 14 deletions(-) create mode 100644 ci/properties/desktop.properties.json diff --git a/ci/desktop.yml b/ci/desktop.yml index 83ff99a..4a2b0a5 100644 --- a/ci/desktop.yml +++ b/ci/desktop.yml @@ -1,4 +1,6 @@ -# This workflow will build, test and create app packages for a Wpf project built on Net Core. +# This workflow will build, test and package a Wpf desktop application built on .NET Core. +# To learn how to migrate your existing WPF application to .NET Core, +# refer to https://docs.microsoft.com/en-us/dotnet/desktop-wpf/migration/convert-project-from-net-framework # # To configure this workflow: # @@ -26,16 +28,13 @@ # For a complete CI/CD sample to get started with GitHub Action workflows for Desktop Applications, # refer to https://github.com/microsoft/github-actions-for-desktop-apps -name: Build and publish a desktop application +name: Build, deploy and publish a Wpf desktop application -# Trigger on every master branch push and pull request on: push: - branches: - - master + branches: [ master ] pull_request: - branches: - - master + branches: [ master ] jobs: @@ -68,14 +67,14 @@ jobs: - name: Install .NET Core uses: actions/setup-dotnet@v1 with: - dotnet-version: 3.1.100 + dotnet-version: 3.1.101 # Add MsBuild to the PATH: https://github.com/microsoft/setup-msbuild - name: Setup MSBuild.exe uses: microsoft/setup-msbuild@v1.0.0 # Test - - name: Execute Unit Tests + - name: Execute unit tests run: dotnet test $env:Test_Project_Path # Restore the Wpf application to populate the obj folder with RuntimeIdentifiers @@ -84,21 +83,21 @@ jobs: env: Configuration: ${{ matrix.configuration }} - # Decode the Base64 encoded Pfx - - name: Decode the Pfx + # Decode the base 64 encoded pfx and save the Signing_Certificate + - name: Decode the pfx run: | $pfx_cert_byte = [System.Convert]::FromBase64String("${{ secrets.Base64_Encoded_Pfx }}") $certificatePath = Join-Path -Path $env:Wap_Project_Directory -ChildPath $env:Signing_Certificate [IO.File]::WriteAllBytes("$certificatePath", $pfx_cert_byte) # Create the app package by building and packaging the Windows Application Packaging project - - name: Create the App Package + - name: Create the app package run: msbuild $env:Wap_Project_Path /p:Configuration=$env:Configuration /p:UapAppxPackageBuildMode=$env:Appx_Package_Build_Mode /p:AppxBundle=$env:Appx_Bundle /p:PackageCertificateKeyFile=$env:Signing_Certificate /p:PackageCertificatePassword=${{ secrets.Pfx_Key }} env: Configuration: ${{ matrix.configuration }} - # Remove the .pfx - - name: Remove the .pfx + # Remove the pfx + - name: Remove the pfx run: Remove-Item -path $env:Wap_Project_Directory\$env:Signing_Certificate # Upload the MSIX package: https://github.com/marketplace/actions/upload-artifact diff --git a/ci/properties/desktop.properties.json b/ci/properties/desktop.properties.json new file mode 100644 index 0000000..e04727e --- /dev/null +++ b/ci/properties/desktop.properties.json @@ -0,0 +1,6 @@ +{ + "name": "Test and publish a Wpf application", + "description": "Build, test and publish a Wpf application built on .NET Core.", + "iconName": "Wpf", + "categories": ["C#", "Visual Basic", "WPF", ".NET"] +} \ No newline at end of file From a2adc6fc7388fe22ccc1b2a05896585ecab5fbf1 Mon Sep 17 00:00:00 2001 From: Edward Skrod Date: Mon, 6 Apr 2020 10:32:56 -0400 Subject: [PATCH 3/6] Updated files with name that conforms to PR recommendations. --- ci/desktop.yml | 2 +- ci/properties/desktop.properties.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/desktop.yml b/ci/desktop.yml index 4a2b0a5..4a06abf 100644 --- a/ci/desktop.yml +++ b/ci/desktop.yml @@ -28,7 +28,7 @@ # For a complete CI/CD sample to get started with GitHub Action workflows for Desktop Applications, # refer to https://github.com/microsoft/github-actions-for-desktop-apps -name: Build, deploy and publish a Wpf desktop application +name: Wpf .NET Core on: push: diff --git a/ci/properties/desktop.properties.json b/ci/properties/desktop.properties.json index e04727e..4a382a2 100644 --- a/ci/properties/desktop.properties.json +++ b/ci/properties/desktop.properties.json @@ -1,5 +1,5 @@ { - "name": "Test and publish a Wpf application", + "name": "Wpf .NET Core", "description": "Build, test and publish a Wpf application built on .NET Core.", "iconName": "Wpf", "categories": ["C#", "Visual Basic", "WPF", ".NET"] From 703084fb8c1a13fb8933c95a9ef500e12da4d2bf Mon Sep 17 00:00:00 2001 From: Edward Skrod Date: Tue, 7 Apr 2020 12:24:02 -0400 Subject: [PATCH 4/6] Renamed files and addressed PR feedback. --- ...s.json => wpf-dotnet-core.properties.json} | 0 ci/{desktop.yml => wpf-dotnet-core.yml} | 31 +++++++++---------- 2 files changed, 15 insertions(+), 16 deletions(-) rename ci/properties/{desktop.properties.json => wpf-dotnet-core.properties.json} (100%) rename ci/{desktop.yml => wpf-dotnet-core.yml} (75%) diff --git a/ci/properties/desktop.properties.json b/ci/properties/wpf-dotnet-core.properties.json similarity index 100% rename from ci/properties/desktop.properties.json rename to ci/properties/wpf-dotnet-core.properties.json diff --git a/ci/desktop.yml b/ci/wpf-dotnet-core.yml similarity index 75% rename from ci/desktop.yml rename to ci/wpf-dotnet-core.yml index 4a06abf..a8241ab 100644 --- a/ci/desktop.yml +++ b/ci/wpf-dotnet-core.yml @@ -1,4 +1,4 @@ -# This workflow will build, test and package a Wpf desktop application built on .NET Core. +# This workflow will build, test and package a WPF desktop application built on .NET Core. # To learn how to migrate your existing WPF application to .NET Core, # refer to https://docs.microsoft.com/en-us/dotnet/desktop-wpf/migration/convert-project-from-net-framework # @@ -11,7 +11,7 @@ # 2. Signing # Generate a signing certificate in the Windows Application Packaging Project or add an existing signing certificate # to the project. Next, use PowerShell to encode the .pfx file using Base64 encoding by running the following Powershell -# script to generate the output file. +# script to generate the output string. # # $pfx_cert = Get-Content '.\SigningCertificate.pfx' -Encoding Byte # [System.Convert]::ToBase64String($pfx_cert) | Out-File 'SigningCertificate_Encoded.txt' @@ -28,7 +28,7 @@ # For a complete CI/CD sample to get started with GitHub Action workflows for Desktop Applications, # refer to https://github.com/microsoft/github-actions-for-desktop-apps -name: Wpf .NET Core +name: WPF .NET Core on: push: @@ -44,14 +44,10 @@ jobs: matrix: configuration: [Debug, Release] - runs-on: windows-latest + 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: - Appx_Bundle: Always # Creates an .msixbundle/.appxbundle with the .msix/.appx files for the platform specified. - App_Packages_Directory: AppPackages # The name of the directory that will contain the application packages. The default is "AppPackages." - Appx_Bundle_Platforms: x86|x64 # Include x86 and x64 platforms in the bundle. Possible values: x86|x64|ARM - Appx_Package_Build_Mode: StoreUpload # Generates the .msixupload/.appxupload file and the _Test folder for sideloading. - Signing_Certificate: GitHubActionsDemo.pfx # The name of the .pfx that will be created by decoding the Base 64 secret and consumed during the packaging step. Solution_Name: your-solution-name # Replace with your solution name, i.e. MyWpfApp.sln. Test_Project_Path: your-test-project-path # Replace with the path to your test project, i.e. MyWpfApp.Tests\MyWpfApp.Tests.csproj. Wap_Project_Directory: your-wap-project-directory-name # Replace with the Wap project directory relative to the solution, i.e. MyWpfApp.Package. @@ -73,12 +69,12 @@ jobs: - name: Setup MSBuild.exe uses: microsoft/setup-msbuild@v1.0.0 - # Test + # Execute all unit tests in the solution - name: Execute unit tests - run: dotnet test $env:Test_Project_Path + run: dotnet test - # Restore the Wpf application to populate the obj folder with RuntimeIdentifiers - - name: Restore the Wpf application + # Restore the WPF application to populate the obj folder with RuntimeIdentifiers + - name: Restore the WPF application run: msbuild $env:Solution_Name /t:Restore /p:Configuration=$env:Configuration env: Configuration: ${{ matrix.configuration }} @@ -87,13 +83,16 @@ jobs: - name: Decode the pfx run: | $pfx_cert_byte = [System.Convert]::FromBase64String("${{ secrets.Base64_Encoded_Pfx }}") - $certificatePath = Join-Path -Path $env:Wap_Project_Directory -ChildPath $env:Signing_Certificate + $certificatePath = Join-Path -Path $env:Wap_Project_Directory -ChildPath GitHubActionsWorkflow.pfx [IO.File]::WriteAllBytes("$certificatePath", $pfx_cert_byte) # Create the app package by building and packaging the Windows Application Packaging project - name: Create the app package - run: msbuild $env:Wap_Project_Path /p:Configuration=$env:Configuration /p:UapAppxPackageBuildMode=$env:Appx_Package_Build_Mode /p:AppxBundle=$env:Appx_Bundle /p:PackageCertificateKeyFile=$env:Signing_Certificate /p:PackageCertificatePassword=${{ 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=${{ secrets.Pfx_Key }} env: + Appx_Bundle: Always + Appx_Bundle_Platforms: x86|x64 + Appx_Package_Build_Mode: StoreUpload Configuration: ${{ matrix.configuration }} # Remove the pfx @@ -105,4 +104,4 @@ jobs: uses: actions/upload-artifact@v1 with: name: MSIX Package - path: ${{ env.Wap_Project_Directory }}\${{ env.App_Packages_Directory }} + path: ${{ env.Wap_Project_Directory }}\AppPackages From a3f957729c2f2ab206a0c109318258edb4f6bf32 Mon Sep 17 00:00:00 2001 From: Edward Skrod Date: Wed, 8 Apr 2020 10:17:52 -0400 Subject: [PATCH 5/6] Responded to PR feedback. Added commit hash to microsoft setup action. --- ci/wpf-dotnet-core.yml | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/ci/wpf-dotnet-core.yml b/ci/wpf-dotnet-core.yml index a8241ab..80ec3e5 100644 --- a/ci/wpf-dotnet-core.yml +++ b/ci/wpf-dotnet-core.yml @@ -1,27 +1,35 @@ -# This workflow will build, test and package a WPF desktop application built on .NET Core. +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +# This workflow will build, test and package a WPF desktop application +# built on .NET Core. # To learn how to migrate your existing WPF application to .NET Core, # refer to https://docs.microsoft.com/en-us/dotnet/desktop-wpf/migration/convert-project-from-net-framework # # To configure this workflow: # # 1. Configure environment variables -# GitHub sets default environment variables for every workflow run. Replace the variables relative to your -# project in the "env" section below. +# GitHub sets default environment variables for every workflow run. +# Replace the variables relative to your project in the "env" section below. # # 2. Signing -# Generate a signing certificate in the Windows Application Packaging Project or add an existing signing certificate -# to the project. Next, use PowerShell to encode the .pfx file using Base64 encoding by running the following Powershell -# script to generate the output string. +# Generate a signing certificate in the Windows Application +# Packaging Project or add an existing signing certificate to the project. +# Next, use PowerShell to encode the .pfx file using Base64 encoding +# by running the following Powershell script to generate the output string: # # $pfx_cert = Get-Content '.\SigningCertificate.pfx' -Encoding Byte # [System.Convert]::ToBase64String($pfx_cert) | Out-File 'SigningCertificate_Encoded.txt' # -# Open the output file, SigningCertificate_Encoded.txt, and copy the string inside. Then, add the string to the repo -# as a GitHub secret and name it "Base64_Encoded_Pfx." -# For more information on how to configure your signing certificate for this workflow, refer -# to https://github.com/microsoft/github-actions-for-desktop-apps#signing +# Open the output file, SigningCertificate_Encoded.txt, and copy the +# string inside. Then, add the string to the repo as a GitHub secret +# and name it "Base64_Encoded_Pfx." +# For more information on how to configure your signing certificate for +# this workflow, refer to https://github.com/microsoft/github-actions-for-desktop-apps#signing # -# Finally, add the signing certificate password to the repo as a secret and name it "Pfx_Key." +# Finally, add the signing certificate password to the repo as a secret and name it "Pfx_Key". # See "Build the Windows Application Packaging project" below to see how the secret is used. # # For more information on GitHub Actions, refer to https://github.com/features/actions @@ -65,9 +73,9 @@ jobs: with: dotnet-version: 3.1.101 - # Add MsBuild to the PATH: https://github.com/microsoft/setup-msbuild + # Add MSBuild to the PATH: https://github.com/microsoft/setup-msbuild - name: Setup MSBuild.exe - uses: microsoft/setup-msbuild@v1.0.0 + uses: microsoft/setup-msbuild@2008f912f56e61277eefaac6d1888b750582aa16 # Execute all unit tests in the solution - name: Execute unit tests From 29e8a67beb08258b8b7f2baa5778c2386169d1e9 Mon Sep 17 00:00:00 2001 From: Edward Skrod Date: Wed, 8 Apr 2020 14:50:15 -0400 Subject: [PATCH 6/6] Fixed case of wpf --- ci/properties/wpf-dotnet-core.properties.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/properties/wpf-dotnet-core.properties.json b/ci/properties/wpf-dotnet-core.properties.json index 4a382a2..56eea90 100644 --- a/ci/properties/wpf-dotnet-core.properties.json +++ b/ci/properties/wpf-dotnet-core.properties.json @@ -1,6 +1,6 @@ { - "name": "Wpf .NET Core", + "name": "WPF .NET Core", "description": "Build, test and publish a Wpf application built on .NET Core.", - "iconName": "Wpf", + "iconName": "WPF", "categories": ["C#", "Visual Basic", "WPF", ".NET"] } \ No newline at end of file