From dc9a863337469d1d24372a2ffd17830891532eec Mon Sep 17 00:00:00 2001 From: Matthew Leibowitz Date: Sat, 31 Oct 2026 03:50:41 +0200 Subject: [PATCH 1/6] Fix snippet CI for MAUI Blazor Hybrid samples Use Snippets 5000 custom build commands to compile each Hybrid sample's web project and referenced shared or hosted WebAssembly projects without restoring native MAUI targets. Document the separate native-platform validation requirement. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- 10.0/MauiBlazorWebIdentity/snippets.5000.json | 4 ++++ 8.0/MauiBlazorWeb/snippets.5000.json | 4 ++++ 9.0/MauiBlazorWeb/snippets.5000.json | 4 ++++ 9.0/MauiBlazorWebIdentity/snippets.5000.json | 4 ++++ CONTRIBUTING.md | 2 ++ 5 files changed, 18 insertions(+) create mode 100644 10.0/MauiBlazorWebIdentity/snippets.5000.json create mode 100644 8.0/MauiBlazorWeb/snippets.5000.json create mode 100644 9.0/MauiBlazorWeb/snippets.5000.json create mode 100644 9.0/MauiBlazorWebIdentity/snippets.5000.json diff --git a/10.0/MauiBlazorWebIdentity/snippets.5000.json b/10.0/MauiBlazorWebIdentity/snippets.5000.json new file mode 100644 index 000000000..625056bc6 --- /dev/null +++ b/10.0/MauiBlazorWebIdentity/snippets.5000.json @@ -0,0 +1,4 @@ +{ + "host": "custom", + "command": "dotnet build \"MauiBlazorWeb.Web/MauiBlazorWeb.Web.csproj\"" +} diff --git a/8.0/MauiBlazorWeb/snippets.5000.json b/8.0/MauiBlazorWeb/snippets.5000.json new file mode 100644 index 000000000..625056bc6 --- /dev/null +++ b/8.0/MauiBlazorWeb/snippets.5000.json @@ -0,0 +1,4 @@ +{ + "host": "custom", + "command": "dotnet build \"MauiBlazorWeb.Web/MauiBlazorWeb.Web.csproj\"" +} diff --git a/9.0/MauiBlazorWeb/snippets.5000.json b/9.0/MauiBlazorWeb/snippets.5000.json new file mode 100644 index 000000000..625056bc6 --- /dev/null +++ b/9.0/MauiBlazorWeb/snippets.5000.json @@ -0,0 +1,4 @@ +{ + "host": "custom", + "command": "dotnet build \"MauiBlazorWeb.Web/MauiBlazorWeb.Web.csproj\"" +} diff --git a/9.0/MauiBlazorWebIdentity/snippets.5000.json b/9.0/MauiBlazorWebIdentity/snippets.5000.json new file mode 100644 index 000000000..8b9403fec --- /dev/null +++ b/9.0/MauiBlazorWebIdentity/snippets.5000.json @@ -0,0 +1,4 @@ +{ + "host": "custom", + "command": "dotnet build \"MauiBlazorWeb/MauiBlazorWeb.Web/MauiBlazorWeb.Web.csproj\"" +} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9f4dbc2c2..01c75218e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -22,6 +22,8 @@ The **Snippets 5000** workflow runs for pull requests that target `main`. It use Review compilation errors in the workflow logs and fix failures in the affected samples before merging. The workflow runs on Windows with the .NET 11 preview SDK and the .NET 10 SDK and runtime. +For .NET MAUI Blazor Hybrid solutions, a `snippets.5000.json` file beside the solution uses the `custom` host to build the web project instead of the full multi-platform solution. This also compiles the referenced shared Razor class library and any hosted WebAssembly client without requiring native MAUI workloads on the runner. This check doesn't validate native apps. Validate native-only changes separately with the appropriate platform-specific MAUI workloads and tooling. + To rerun the check manually, select **Actions** > **Snippets 5000** > **Run workflow** and enter the pull request number. The workflow checks out that pull request's merge ref and builds its affected samples. ## Related content From a0e7a09a78419606147528d4ce1e86e2aeaea750 Mon Sep 17 00:00:00 2001 From: Matthew Leibowitz Date: Sat, 31 Oct 2026 06:06:00 +0200 Subject: [PATCH 2/6] Build MAUI native apps in sample CI Add affected-sample native build jobs for Android, Windows, iOS Simulator, and Mac Catalyst alongside the existing web/shared/WASM checks. Pin matching SDK/workload and Xcode combinations, isolate SDK installs, and scope native restore without retargeting referenced shared libraries. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .github/maui-ci.targets | 5 ++ .github/workflows/snippets5000.yml | 134 +++++++++++++++++++++++++++++ CONTRIBUTING.md | 8 +- 3 files changed, 145 insertions(+), 2 deletions(-) create mode 100644 .github/maui-ci.targets diff --git a/.github/maui-ci.targets b/.github/maui-ci.targets new file mode 100644 index 000000000..7cfcd93c6 --- /dev/null +++ b/.github/maui-ci.targets @@ -0,0 +1,5 @@ + + + $(MauiCITargetFramework) + + diff --git a/.github/workflows/snippets5000.yml b/.github/workflows/snippets5000.yml index 033dd48dc..f9cb5539b 100644 --- a/.github/workflows/snippets5000.yml +++ b/.github/workflows/snippets5000.yml @@ -21,6 +21,57 @@ permissions: pull-requests: read jobs: + maui-projects: + runs-on: ubuntu-latest + outputs: + samples: ${{ steps.samples.outputs.samples }} + steps: + - name: Harden Runner + uses: step-security/harden-runner@dc2769abcc0fcfbadfc1df54081c1608579ef6b2 # v2.22.2 + with: + egress-policy: audit + + - name: Find affected MAUI samples + id: samples + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 + env: + PR_NUMBER: ${{ github.event.pull_request.number || inputs.pull_request }} + with: + script: | + const files = await github.paginate(github.rest.pulls.listFiles, { + ...context.repo, + pull_number: Number(process.env.PR_NUMBER) + }); + const paths = files.flatMap(file => [file.filename, file.previous_filename].filter(Boolean)); + const ciChanged = paths.some(path => ['.github/workflows/snippets5000.yml', '.github/maui-ci.targets'].includes(path)); + const builds = [ + { + version: '8.0', sdk: '8.0.427', macos: 'macos-15', xcode: '16.0', + projects: [ + { root: '8.0/MauiBlazorWeb/', path: '8.0/MauiBlazorWeb/MauiBlazorWeb.Maui/MauiBlazorWeb.Maui.csproj' } + ] + }, + { + version: '9.0', sdk: '9.0.320', macos: 'macos-26', xcode: '26.5', + projects: [ + { root: '9.0/MauiBlazorWeb/', path: '9.0/MauiBlazorWeb/MauiBlazorWeb/MauiBlazorWeb.csproj' }, + { root: '9.0/MauiBlazorWebIdentity/', path: '9.0/MauiBlazorWebIdentity/MauiBlazorWeb/MauiBlazorWeb/MauiBlazorWeb.csproj' } + ] + }, + { + version: '10.0', sdk: '10.0.400', macos: 'macos-26', xcode: '26.6', + projects: [ + { root: '10.0/MauiBlazorWebIdentity/', path: '10.0/MauiBlazorWebIdentity/MauiBlazorWeb/MauiBlazorWeb.csproj' } + ] + } + ]; + for (const build of builds) { + build.projects = build.projects + .filter(project => ciChanged || paths.some(path => path.startsWith(project.root))) + .map(project => project.path); + } + core.setOutput('samples', JSON.stringify(builds.filter(build => build.projects.length > 0))); + snippets-build: runs-on: windows-2022 @@ -60,3 +111,86 @@ jobs: REPOSITORY_NAME: ${{ github.event.repository.name }} run: | dotnet run --project docs-tools\snippets5000\Snippets5000\Snippets5000.csproj -- --sourcepath "$env:GITHUB_WORKSPACE" --pullrequest "$env:PR_NUMBER" --owner "$env:REPOSITORY_OWNER" --repo "$env:REPOSITORY_NAME" + + maui-build: + name: MAUI .NET ${{ matrix.sample.version }} (${{ matrix.platform }}) + needs: maui-projects + if: needs.maui-projects.outputs.samples != '[]' + strategy: + fail-fast: false + matrix: + sample: ${{ fromJSON(needs.maui-projects.outputs.samples) }} + platform: [windows, macos] + runs-on: ${{ matrix.platform == 'windows' && 'windows-2022' || matrix.sample.macos }} + timeout-minutes: 45 + defaults: + run: + shell: pwsh + env: + SDK_VERSION: ${{ matrix.sample.sdk }} + FRAMEWORK_VERSION: ${{ matrix.sample.version }} + PROJECTS: ${{ toJSON(matrix.sample.projects) }} + DEVELOPER_DIR: /Applications/Xcode_${{ matrix.sample.xcode }}.app/Contents/Developer + + steps: + - name: Harden Runner + uses: step-security/harden-runner@dc2769abcc0fcfbadfc1df54081c1608579ef6b2 # v2.22.2 + with: + egress-policy: audit + + - name: Checkout repository + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + ref: ${{ github.event_name == 'workflow_dispatch' && format('refs/pull/{0}/merge', inputs.pull_request) || github.ref }} + persist-credentials: false + + - name: Setup .NET + uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0 + env: + DOTNET_INSTALL_DIR: ${{ runner.temp }}/dotnet + with: + dotnet-version: ${{ matrix.sample.sdk }} + + - name: Select native-build SDK + run: dotnet new globaljson --sdk-version "$env:SDK_VERSION" --roll-forward disable + + - name: Setup Java + if: runner.os == 'Windows' + uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0 + with: + distribution: temurin + java-version: '17' + + - name: Display Xcode version + if: runner.os == 'macOS' + run: xcodebuild -version + + - name: Install native workloads + run: | + $workloads = if ($IsWindows) { @('maui-android', 'maui-windows') } else { @('maui-ios', 'maui-maccatalyst') } + dotnet workload install @workloads --version "$env:SDK_VERSION" + + - name: Build native apps + run: | + $projects = $env:PROJECTS | ConvertFrom-Json + $frameworks = if ($IsWindows) { @('android', 'windows10.0.19041.0') } else { @('ios', 'maccatalyst') } + $architecture = [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture.ToString().ToLowerInvariant() + $targetsPath = Join-Path $env:GITHUB_WORKSPACE '.github/maui-ci.targets' + foreach ($project in $projects) { + foreach ($platform in $frameworks) { + $framework = "net$env:FRAMEWORK_VERSION-$platform" + $buildArguments = @($project, '--configuration', 'Debug', '--framework', $framework, "-p:MauiCITargetFramework=$framework", "-p:DirectoryBuildTargetsPath=$targetsPath") + if ($platform -eq 'android') { + dotnet build @buildArguments '-t:InstallAndroidDependencies' "-p:AndroidSdkDirectory=$env:ANDROID_HOME" "-p:JavaSdkDirectory=$env:JAVA_HOME" '-p:AcceptAndroidSDKLicenses=true' + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } + } elseif ($platform -eq 'ios') { + $buildArguments += @("-p:RuntimeIdentifier=iossimulator-$architecture", '-p:EnableCodeSigning=false') + } elseif ($platform -eq 'maccatalyst') { + $buildArguments += @("-p:RuntimeIdentifier=maccatalyst-$architecture", '-p:EnableCodeSigning=false') + } else { + $buildArguments += '-p:WindowsPackageType=None' + } + dotnet build @buildArguments + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } + } + } diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 01c75218e..178987a0c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -20,9 +20,13 @@ You need a basic understanding of [Git and GitHub.com](https://guides.github.com The **Snippets 5000** workflow runs for pull requests that target `main`. It uses [Snippets5000](https://github.com/dotnet/docs-tools/tree/main/snippets5000) to discover and compile sample projects and solutions affected by changes to code files, Razor files, project files, solution files, or build configuration files such as `global.json` and `snippets.5000.json`. -Review compilation errors in the workflow logs and fix failures in the affected samples before merging. The workflow runs on Windows with the .NET 11 preview SDK and the .NET 10 SDK and runtime. +Review compilation errors in the workflow logs and fix failures in the affected samples before merging. The general snippet build runs on Windows with the .NET 11 preview SDK and the .NET 10 SDK and runtime. -For .NET MAUI Blazor Hybrid solutions, a `snippets.5000.json` file beside the solution uses the `custom` host to build the web project instead of the full multi-platform solution. This also compiles the referenced shared Razor class library and any hosted WebAssembly client without requiring native MAUI workloads on the runner. This check doesn't validate native apps. Validate native-only changes separately with the appropriate platform-specific MAUI workloads and tooling. +For .NET MAUI Blazor Hybrid solutions, a `snippets.5000.json` file beside the solution uses the `custom` host to build the web project. This also compiles the referenced shared Razor class library and any hosted WebAssembly client. + +Separate native-build jobs compile affected Hybrid samples for Android and Windows on Windows, and for iOS Simulator and Mac Catalyst on macOS. These jobs install matching .NET SDKs and MAUI workload sets, select compatible Xcode versions, and use `.github/maui-ci.targets` to limit native restore and build to the platform being checked without retargeting shared projects. Apple builds don't require distribution certificates, and no devices or simulators are launched. Changes to the workflow or CI targets file rebuild all four Hybrid samples; otherwise, only samples with changes under their solution directory are selected. + +When adding another Hybrid sample, update the native-build matrix in `.github/workflows/snippets5000.yml`. Keep pinned SDK/workload sets and Xcode versions compatible when updating the toolchains. To rerun the check manually, select **Actions** > **Snippets 5000** > **Run workflow** and enter the pull request number. The workflow checks out that pull request's merge ref and builds its affected samples. From bbf88cb78f365c1f467ecaf351aec4e2beb3443b Mon Sep 17 00:00:00 2001 From: Matthew Leibowitz Date: Sat, 31 Oct 2026 06:14:53 +0200 Subject: [PATCH 3/6] Use the canonical Xcode directory for .NET 8 CI Avoid the hosted runner's Xcode_16.0.app symlink, which triggers the older Apple workload's ACTool SDK lookup failure. Use the actual Xcode_16.app installation documented by the runner image. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .github/workflows/snippets5000.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/snippets5000.yml b/.github/workflows/snippets5000.yml index f9cb5539b..bfc37d03b 100644 --- a/.github/workflows/snippets5000.yml +++ b/.github/workflows/snippets5000.yml @@ -46,7 +46,8 @@ jobs: const ciChanged = paths.some(path => ['.github/workflows/snippets5000.yml', '.github/maui-ci.targets'].includes(path)); const builds = [ { - version: '8.0', sdk: '8.0.427', macos: 'macos-15', xcode: '16.0', + // .NET 8's ACTool can't use the Xcode_16.0.app symlink (dotnet/macios#21762). + version: '8.0', sdk: '8.0.427', macos: 'macos-15', xcode: '16', projects: [ { root: '8.0/MauiBlazorWeb/', path: '8.0/MauiBlazorWeb/MauiBlazorWeb.Maui/MauiBlazorWeb.Maui.csproj' } ] From b17675e3a55bd828d496d902c6ef499e9df8dc4b Mon Sep 17 00:00:00 2001 From: Matthew Leibowitz Date: Sat, 31 Oct 2026 06:23:56 +0200 Subject: [PATCH 4/6] Install the legacy iOS asset compiler runtime in CI Provision iOS 18.0 for the .NET 8/Xcode 16 job. The current hosted image no longer includes that simulator runtime, which ACTool requires to compile assets even without launching a simulator. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .github/workflows/snippets5000.yml | 4 ++++ CONTRIBUTING.md | 2 ++ 2 files changed, 6 insertions(+) diff --git a/.github/workflows/snippets5000.yml b/.github/workflows/snippets5000.yml index bfc37d03b..10a1a53c0 100644 --- a/.github/workflows/snippets5000.yml +++ b/.github/workflows/snippets5000.yml @@ -166,6 +166,10 @@ jobs: if: runner.os == 'macOS' run: xcodebuild -version + - name: Install iOS 18 simulator runtime for the .NET 8 asset compiler + if: runner.os == 'macOS' && matrix.sample.version == '8.0' + run: xcodebuild -downloadPlatform iOS -buildVersion '18.0' + - name: Install native workloads run: | $workloads = if ($IsWindows) { @('maui-android', 'maui-windows') } else { @('maui-ios', 'maui-maccatalyst') } diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 178987a0c..b86cafd31 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -26,6 +26,8 @@ For .NET MAUI Blazor Hybrid solutions, a `snippets.5000.json` file beside the so Separate native-build jobs compile affected Hybrid samples for Android and Windows on Windows, and for iOS Simulator and Mac Catalyst on macOS. These jobs install matching .NET SDKs and MAUI workload sets, select compatible Xcode versions, and use `.github/maui-ci.targets` to limit native restore and build to the platform being checked without retargeting shared projects. Apple builds don't require distribution certificates, and no devices or simulators are launched. Changes to the workflow or CI targets file rebuild all four Hybrid samples; otherwise, only samples with changes under their solution directory are selected. +The .NET 8 Apple build also installs the iOS 18 simulator runtime required by Xcode 16's asset compiler, even though no simulator is launched. + When adding another Hybrid sample, update the native-build matrix in `.github/workflows/snippets5000.yml`. Keep pinned SDK/workload sets and Xcode versions compatible when updating the toolchains. To rerun the check manually, select **Actions** > **Snippets 5000** > **Run workflow** and enter the pull request number. The workflow checks out that pull request's merge ref and builds its affected samples. From e08b2bd8e2caa01787b414be771ca4cad98bb38d Mon Sep 17 00:00:00 2001 From: Matthew Leibowitz Date: Sat, 31 Oct 2026 06:32:32 +0200 Subject: [PATCH 5/6] Use a runtime downloader that supports selecting iOS versions Use the hosted runner's Xcode 26.3 CLI only for downloading iOS 18.0, since Xcode 16.0 lacks the buildVersion option. Keep native .NET 8 compilation on its matching canonical Xcode 16 installation. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .github/workflows/snippets5000.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/snippets5000.yml b/.github/workflows/snippets5000.yml index 10a1a53c0..c4bb57709 100644 --- a/.github/workflows/snippets5000.yml +++ b/.github/workflows/snippets5000.yml @@ -168,6 +168,9 @@ jobs: - name: Install iOS 18 simulator runtime for the .NET 8 asset compiler if: runner.os == 'macOS' && matrix.sample.version == '8.0' + env: + # Xcode 16.0 can't select runtime download versions; native compilation still uses Xcode 16. + DEVELOPER_DIR: /Applications/Xcode_26.3.app/Contents/Developer run: xcodebuild -downloadPlatform iOS -buildVersion '18.0' - name: Install native workloads From 3eafb6b2d44b3a6a0daed4d1d5cc8dbb924187d4 Mon Sep 17 00:00:00 2001 From: Matthew Leibowitz Date: Sat, 31 Oct 2026 06:40:19 +0200 Subject: [PATCH 6/6] Use the complete hosted Xcode 16.4 toolchain for .NET 8 Select the preinstalled Xcode 16.4 SDK and matching simulator runtime instead of depending on a legacy iOS 18.0 runtime download. Keep native platform compilation and remove the failed cross-version runtime provisioning path. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .github/workflows/snippets5000.yml | 10 +--------- CONTRIBUTING.md | 2 -- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/.github/workflows/snippets5000.yml b/.github/workflows/snippets5000.yml index c4bb57709..cb0db1bfb 100644 --- a/.github/workflows/snippets5000.yml +++ b/.github/workflows/snippets5000.yml @@ -46,8 +46,7 @@ jobs: const ciChanged = paths.some(path => ['.github/workflows/snippets5000.yml', '.github/maui-ci.targets'].includes(path)); const builds = [ { - // .NET 8's ACTool can't use the Xcode_16.0.app symlink (dotnet/macios#21762). - version: '8.0', sdk: '8.0.427', macos: 'macos-15', xcode: '16', + version: '8.0', sdk: '8.0.427', macos: 'macos-15', xcode: '16.4', projects: [ { root: '8.0/MauiBlazorWeb/', path: '8.0/MauiBlazorWeb/MauiBlazorWeb.Maui/MauiBlazorWeb.Maui.csproj' } ] @@ -166,13 +165,6 @@ jobs: if: runner.os == 'macOS' run: xcodebuild -version - - name: Install iOS 18 simulator runtime for the .NET 8 asset compiler - if: runner.os == 'macOS' && matrix.sample.version == '8.0' - env: - # Xcode 16.0 can't select runtime download versions; native compilation still uses Xcode 16. - DEVELOPER_DIR: /Applications/Xcode_26.3.app/Contents/Developer - run: xcodebuild -downloadPlatform iOS -buildVersion '18.0' - - name: Install native workloads run: | $workloads = if ($IsWindows) { @('maui-android', 'maui-windows') } else { @('maui-ios', 'maui-maccatalyst') } diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b86cafd31..178987a0c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -26,8 +26,6 @@ For .NET MAUI Blazor Hybrid solutions, a `snippets.5000.json` file beside the so Separate native-build jobs compile affected Hybrid samples for Android and Windows on Windows, and for iOS Simulator and Mac Catalyst on macOS. These jobs install matching .NET SDKs and MAUI workload sets, select compatible Xcode versions, and use `.github/maui-ci.targets` to limit native restore and build to the platform being checked without retargeting shared projects. Apple builds don't require distribution certificates, and no devices or simulators are launched. Changes to the workflow or CI targets file rebuild all four Hybrid samples; otherwise, only samples with changes under their solution directory are selected. -The .NET 8 Apple build also installs the iOS 18 simulator runtime required by Xcode 16's asset compiler, even though no simulator is launched. - When adding another Hybrid sample, update the native-build matrix in `.github/workflows/snippets5000.yml`. Keep pinned SDK/workload sets and Xcode versions compatible when updating the toolchains. To rerun the check manually, select **Actions** > **Snippets 5000** > **Run workflow** and enter the pull request number. The workflow checks out that pull request's merge ref and builds its affected samples.