organize folder #12
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This workflow will build a .NET project | |
| # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net | |
| name: Build project on Windows | |
| on: | |
| push: | |
| branches: [ "main" ] | |
| paths-ignore: | |
| - "**.md" | |
| pull_request: | |
| branches: [ "main" ] | |
| workflow_dispatch: | |
| env: | |
| LIB_CSPROJ: src/PJ.ContextActions.Maui/PJ.ContextActions.Maui.csproj | |
| SAMPLE_CSPROJ: samples/PJ.ContextActions.Sample/PJ.ContextActions.Sample.csproj | |
| NugetPackageVersion: '99.0.0-preview${{ github.run_number }}' | |
| CurrentSemanticVersionBase: '99.0.0' | |
| Package_Creation_Path: './src/PJ.ContextActions.Maui/bin/Release' | |
| MSBUILD_PATH: 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\MSBuild.exe' | |
| jobs: | |
| build: | |
| runs-on: windows-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: 9.0.x | |
| - name: Get Nuget version and Name for PR | |
| if: ${{ github.event_name == 'pull_request' }} | |
| run: | | |
| echo "NugetPackageVersion=${{ env.CurrentSemanticVersionBase }}-build-${{ github.event.pull_request.number }}.${{ github.run_number }}+${{ github.sha }}" | |
| shell: bash | |
| - name: Workload install | |
| run: | | |
| dotnet workload install maui | |
| dotnet workload install maui-windows | |
| dotnet workload update | |
| # Windows builds using MSBuild | |
| - name: Find MSBuild | |
| run: | | |
| $msbuildPath = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -products * -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe | |
| echo "MSBUILD_PATH=$msbuildPath" >> $env:GITHUB_ENV | |
| shell: pwsh | |
| - name: Restore library dependencies (Windows) | |
| run: | | |
| & "${{ env.MSBUILD_PATH }}" ${{env.LIB_CSPROJ}} /t:Restore /p:TargetFramework=net9.0-windows10.0.19041.0 /p:RuntimeIdentifier=win10-x64 | |
| shell: cmd | |
| - name: Build library (Windows) | |
| run: | | |
| & "${{ env.MSBUILD_PATH }}" ${{env.LIB_CSPROJ}} /p:Configuration=Release /p:TargetFramework=net9.0-windows10.0.19041.0 /p:RuntimeIdentifier=win10-x64 /p:PackageVersion=${{ env.NugetPackageVersion }} /p:Version=${{ env.NugetPackageVersion }} | |
| shell: cmd | |
| - name: Restore sample dependencies (Windows) | |
| run: | | |
| & "${{ env.MSBUILD_PATH }}" ${{env.SAMPLE_CSPROJ}} /t:Restore /p:TargetFramework=net9.0-windows10.0.19041.0 /p:RuntimeIdentifier=win10-x64 | |
| shell: cmd | |
| - name: Build Sample app (Windows) | |
| run: | | |
| & "${{ env.MSBUILD_PATH }}" ${{env.SAMPLE_CSPROJ}} /p:Configuration=Release /p:TargetFramework=net9.0-windows10.0.19041.0 /p:RuntimeIdentifier=win10-x64 | |
| shell: cmd | |
| # Android builds using dotnet build | |
| - name: Restore library dependencies | |
| run: dotnet restore ${{env.LIB_CSPROJ}} | |
| - name: Build library (Android) | |
| run: dotnet build ${{env.LIB_CSPROJ}} -c Release -f net9.0-android -p:PackageVersion=${{ env.NugetPackageVersion }} -p:Version=${{ env.NugetPackageVersion }} --no-restore | |
| - name: Restore sample dependencies | |
| run: dotnet restore ${{env.SAMPLE_CSPROJ}} | |
| - name: Build Sample app (Android) | |
| run: dotnet build ${{env.SAMPLE_CSPROJ}} -c Release -f net9.0-android --no-restore | |
| # NuGet packaging - this will package all platforms that were built | |
| - name: Create Nuget | |
| run: dotnet pack ${{env.LIB_CSPROJ}} -c Release --no-restore --no-build --include-symbols --include-source | |
| - name: Copy NuGet Packages to Staging Directory | |
| if: ${{ runner.os == 'Windows' && !startsWith(github.ref, 'refs/tags/') }} | |
| run: | | |
| mkdir -p ${{ github.workspace }}/nuget | |
| Get-ChildItem -Path ${{env.Package_Creation_Path}} -Recurse | Where-Object { $_.Extension -match "nupkg" } | Copy-Item -Destination "${{ github.workspace }}/nuget" | |
| shell: pwsh | |
| - name: List NuGet packages found | |
| run: | | |
| Get-ChildItem -Path "${{ github.workspace }}/nuget" | Format-Table Name | |
| shell: pwsh | |
| - name: Publish Packages | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: packages | |
| path: ${{ github.workspace }}/nuget/ |