diff --git a/.github/actions/environment/action.yml b/.github/actions/environment/action.yml index 3754453a45..a55f337a4f 100644 --- a/.github/actions/environment/action.yml +++ b/.github/actions/environment/action.yml @@ -93,8 +93,11 @@ runs: dotnet workload restore \ --temp-dir "${{ runner.temp }}" \ --skip-sign-check - dotnet workload restore test/AndroidTestApp/AndroidTestApp.csproj \ - --temp-dir "${{ runner.temp }}" \ - --skip-sign-check - # Restore the Android test app explicitly to ensure runtime packs are available - dotnet restore test/AndroidTestApp/AndroidTestApp.csproj -r android-x64 --nologo || true + # The Windows solution filters exclude the Android test app and the tests that build it + if [[ "$RUNNER_OS" != "Windows" ]]; then + dotnet workload restore test/AndroidTestApp/AndroidTestApp.csproj \ + --temp-dir "${{ runner.temp }}" \ + --skip-sign-check + # Restore the Android test app explicitly to ensure runtime packs are available + dotnet restore test/AndroidTestApp/AndroidTestApp.csproj -r android-x64 --nologo || true + fi diff --git a/.github/actions/windows-dotnet-drive/action.yml b/.github/actions/windows-dotnet-drive/action.yml new file mode 100644 index 0000000000..1e0a2a1ed3 --- /dev/null +++ b/.github/actions/windows-dotnet-drive/action.yml @@ -0,0 +1,42 @@ +name: Windows .NET drive +description: Installs .NET and the NuGet packages on a fast drive on Windows runners +runs: + using: composite + + steps: + # The Windows images keep .NET under Program Files, where workloads install as MSI packages, and the NuGet cache + # in the user profile on C:. So .NET goes next to the workspace, where workloads install as plain files. The x64 + # runners put the workspace on D:, so the NuGet packages go there too. The arm64 runners only have C:, so the + # NuGet packages and TEMP go on a Dev Drive there. Defender already excludes C:\ on these images. + - name: Install .NET and NuGet packages on a fast drive + shell: pwsh + run: | + $root = Split-Path $env:GITHUB_WORKSPACE + "DOTNET_INSTALL_DIR=$root\.dotnet" >> $env:GITHUB_ENV + if ($root.StartsWith('C:')) + { + # Only volumes mounted after this get no antivirus filters + fsutil devdrv enable /disallowAv | Out-Host + 'create vdisk file="C:\devdrive.vhdx" maximum=81920 type=expandable', 'select vdisk file="C:\devdrive.vhdx"', 'attach vdisk', 'convert gpt', 'create partition primary' | + Set-Content "$env:RUNNER_TEMP\diskpart.txt" + diskpart /s "$env:RUNNER_TEMP\diskpart.txt" | Out-Host + if ($LASTEXITCODE -ne 0) { throw "diskpart failed with exit code $LASTEXITCODE" } + $partition = Get-DiskImage -ImagePath 'C:\devdrive.vhdx' | Get-Disk | Get-Partition | Where-Object Type -eq 'Basic' + $partition | Format-Volume -DevDrive -Confirm:$false -Force | Out-Host + $partition | Add-PartitionAccessPath -AccessPath 'X:\' + # Right after the mount, trust can fail with "Access is denied" while the volume is still in use + for ($attempt = 1; $attempt -le 5; $attempt++) + { + fsutil devdrv trust X: | Out-Host + if ($LASTEXITCODE -eq 0) { break } + Start-Sleep -Seconds 3 + } + if ($LASTEXITCODE -ne 0) { Write-Warning "Couldn't mark X: as a trusted Dev Drive, so antivirus filters may still scan it" } + fsutil devdrv query X: | Out-Host + $root = 'X:' + New-Item -ItemType Directory "$root\tmp" | Out-Null + "TEMP=$root\tmp" >> $env:GITHUB_ENV + "TMP=$root\tmp" >> $env:GITHUB_ENV + } + "NUGET_PACKAGES=$root\.nuget\packages" >> $env:GITHUB_ENV + $global:LASTEXITCODE = 0 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b3b3ad321b..d38c3ef20a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -143,6 +143,10 @@ jobs: if: ${{ !matrix.container }} uses: ./.github/actions/freediskspace + - name: Install .NET and NuGet packages on a fast drive + if: runner.os == 'Windows' + uses: ./.github/actions/windows-dotnet-drive + - name: Setup Environment uses: ./.github/actions/environment @@ -347,6 +351,9 @@ jobs: with: submodules: recursive + - name: Install .NET and NuGet packages on a fast drive + uses: ./.github/actions/windows-dotnet-drive + - name: Download sentry-native (win-x64) uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 with: diff --git a/.github/workflows/verify-api.yml b/.github/workflows/verify-api.yml index 5e4ccf5115..e55fd61180 100644 --- a/.github/workflows/verify-api.yml +++ b/.github/workflows/verify-api.yml @@ -42,6 +42,10 @@ jobs: - name: Remove unused applications uses: ./.github/actions/freediskspace + - name: Install .NET and NuGet packages on a fast drive + if: runner.os == 'Windows' + uses: ./.github/actions/windows-dotnet-drive + - name: Setup Environment uses: ./.github/actions/environment