diff --git a/.github/actions/environment/action.yml b/.github/actions/environment/action.yml index 7b7650d51d..5e4c5e836f 100644 --- a/.github/actions/environment/action.yml +++ b/.github/actions/environment/action.yml @@ -11,16 +11,24 @@ runs: echo "DOTNET_CLI_TELEMETRY_OPTOUT=1" >> $GITHUB_ENV echo "DOTNET_NOLOGO=1" >> $GITHUB_ENV + # zstd is needed for cross OS actions/cache but missing from windows-11-arm + # https://github.com/actions/partner-runner-images/issues/99 + - name: Install zstd on Windows ARM64 + if: runner.os == 'Windows' && runner.arch == 'ARM64' + shell: pwsh + run: choco install zstandard + # See https://github.com/actions/runner-images/blob/main/images/macos/macos-15-Readme.md#xcode - name: Pin the Xcode Version if: runner.os == 'macOS' shell: bash run: sudo xcode-select --switch /Applications/Xcode_16.2.app - # Needed for Android SDK setup step - - uses: actions/setup-java@v3 + # Java 17 is needed for Android SDK setup step + - name: Install Java 17 + uses: actions/setup-java@v4 with: - distribution: 'temurin' + distribution: ${{ runner.os == 'Windows' && runner.arch == 'ARM64' && 'microsoft' || 'temurin' }} java-version: '17' - name: Setup Android SDK @@ -28,10 +36,11 @@ runs: with: log-accepted-android-sdk-licenses: false - - name: Set Java Version - uses: actions/setup-java@v3 + # Java 11 is needed by .NET Android + - name: Install Java 11 + uses: actions/setup-java@v4 with: - distribution: 'temurin' + distribution: ${{ runner.os == 'Windows' && runner.arch == 'ARM64' && 'microsoft' || 'temurin' }} java-version: '11' - name: Install Mono diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8f1970c21f..d072f1fb6b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,9 +16,12 @@ jobs: strategy: fail-fast: false matrix: - # Pin ubuntu to ensure mono is installed - # Pin macos to get the version of Xcode that we need: https://github.com/actions/runner-images/issues/10703 - os: [ubuntu-22.04, windows-latest, macos-15] + include: + - os: ubuntu-22.04 # Pin ubuntu to ensure mono is installed + - os: macos-15 # Pin macos to get the version of Xcode that we need: https://github.com/actions/runner-images/issues/10703 + - os: windows-latest + - os: windows-11-arm + target: Windows-arm64 steps: - name: Checkout @@ -26,11 +29,18 @@ jobs: - run: git submodule update --init modules/sentry-native + # zstd is needed for cross OS actions/cache but missing from windows-11-arm + # https://github.com/actions/partner-runner-images/issues/99 + - name: Install zstd on Windows ARM64 + if: runner.os == 'Windows' && runner.arch == 'ARM64' + shell: pwsh + run: choco install zstandard + - uses: actions/cache@v4 id: cache with: path: src/Sentry/Platforms/Native/sentry-native - key: sentry-native-${{ runner.os }}-${{ hashFiles('scripts/build-sentry-native.ps1') }}-${{ hashFiles('.git/modules/modules/sentry-native/HEAD') }} + key: sentry-native-${{ matrix.target || runner.os }}-${{ hashFiles('scripts/build-sentry-native.ps1') }}-${{ hashFiles('.git/modules/modules/sentry-native/HEAD') }} enableCrossOsArchive: true - name: Remove unused applications @@ -54,9 +64,12 @@ jobs: strategy: fail-fast: false matrix: - # Pin ubuntu to ensure mono is installed - # Pin macos to get the version of Xcode that we need: https://github.com/actions/runner-images/issues/10703 - os: [ubuntu-22.04, windows-latest, macos-15] + include: + - os: ubuntu-22.04 # Pin ubuntu to ensure mono is installed + - os: macos-15 # Pin macos to get the version of Xcode that we need: https://github.com/actions/runner-images/issues/10703 + - os: windows-latest + - os: windows-11-arm + target: Windows-arm64 steps: - name: Cancel Previous Runs @@ -72,6 +85,9 @@ jobs: - name: Remove unused applications uses: ./.github/actions/freediskspace + - name: Setup Environment + uses: ./.github/actions/environment + # We use macOS for the final publishing build so we get all the iOS/macCatalyst targets in the packages - name: Set Environment Variables if: runner.os == 'macOS' @@ -94,7 +110,7 @@ jobs: fail-on-cache-miss: true - name: Download sentry-native (Windows) - if: ${{ (env.CI_PUBLISHING_BUILD == 'true') || (runner.os == 'Windows') }} + if: ${{ (env.CI_PUBLISHING_BUILD == 'true') || (runner.os == 'Windows' && runner.arch == 'X64') }} uses: actions/cache/restore@v4 with: path: src/Sentry/Platforms/Native/sentry-native @@ -102,28 +118,34 @@ jobs: fail-on-cache-miss: true enableCrossOsArchive: true - - name: Setup Environment - uses: ./.github/actions/environment + - name: Download sentry-native (Windows arm64) + if: ${{ (env.CI_PUBLISHING_BUILD == 'true') || (runner.os == 'Windows' && runner.arch == 'ARM64') }} + uses: actions/cache/restore@v4 + with: + path: src/Sentry/Platforms/Native/sentry-native + key: sentry-native-Windows-arm64-${{ hashFiles('scripts/build-sentry-native.ps1') }}-${{ hashFiles('.git/modules/modules/sentry-native/HEAD') }} + fail-on-cache-miss: true + enableCrossOsArchive: true - name: Build Native Dependencies uses: ./.github/actions/buildnative - name: Restore .NET Dependencies - run: dotnet restore Sentry-CI-Build-${{ runner.os }}.slnf --nologo + run: dotnet restore Sentry-CI-Build-${{ matrix.target || runner.os }}.slnf --nologo - name: Build id: build - run: dotnet build Sentry-CI-Build-${{ runner.os }}.slnf -c Release --no-restore --nologo -v:minimal -flp:logfile=build.log -p:CopyLocalLockFileAssemblies=true -bl:build.binlog + run: dotnet build Sentry-CI-Build-${{ matrix.target || runner.os }}.slnf -c Release --no-restore --nologo -v:minimal -flp:logfile=build.log -p:CopyLocalLockFileAssemblies=true -bl:build.binlog - name: Upload build logs if: ${{ steps.build.outcome != 'skipped' }} uses: actions/upload-artifact@v4 with: - name: ${{ runner.os }}-build-logs + name: ${{ matrix.target || runner.os }}-build-logs path: build.binlog - name: Test - run: dotnet test Sentry-CI-Build-${{ runner.os }}.slnf -c Release --no-build --nologo -l GitHubActions -l "trx;LogFilePrefix=testresults_${{ runner.os }}" --collect "XPlat Code Coverage" + run: dotnet test Sentry-CI-Build-${{ matrix.target || runner.os }}.slnf -c Release --no-build --nologo -l GitHubActions -l "trx;LogFilePrefix=testresults_${{ runner.os }}" --collect "XPlat Code Coverage" - name: Upload code coverage uses: codecov/codecov-action@ad3126e916f78f00edff4ed0317cf185271ccc2d @@ -132,16 +154,16 @@ jobs: if: failure() uses: actions/upload-artifact@v4 with: - name: ${{ runner.os }}-verify-test-results + name: ${{ matrix.target || runner.os }}-verify-test-results path: "**/*.received.*" - # To save time and disk space, we only create and archive the Nuget packages when we're actually releasing. + # To save time and disk space, we only create and archive the NuGet packages when we're actually releasing. - - name: Create Nuget Packages + - name: Create NuGet Packages if: env.CI_PUBLISHING_BUILD == 'true' - run: dotnet pack Sentry-CI-Build-${{ runner.os }}.slnf -c Release --no-build --nologo + run: dotnet pack Sentry-CI-Build-${{ matrix.target || runner.os }}.slnf -c Release --no-build --nologo - - name: Archive Nuget Packages + - name: Archive NuGet Packages if: env.CI_PUBLISHING_BUILD == 'true' uses: actions/upload-artifact@v4 with: @@ -159,9 +181,11 @@ jobs: strategy: fail-fast: false matrix: - # Pin ubuntu to ensure mono is installed - # Pin macos to get the version of Xcode that we need: https://github.com/actions/runner-images/issues/10703 - os: [ubuntu-22.04, windows-latest, macos-15] + include: + - os: ubuntu-22.04 # Pin ubuntu to ensure mono is installed + - os: macos-15 # Pin macos to get the version of Xcode that we need: https://github.com/actions/runner-images/issues/10703 + - os: windows-latest + - os: windows-11-arm steps: - uses: actions/checkout@v4 @@ -173,7 +197,7 @@ jobs: integration-test .github - - name: Fetch Nuget Packages + - name: Fetch NuGet Packages uses: actions/download-artifact@v4 with: name: ${{ github.sha }} @@ -195,6 +219,7 @@ jobs: trim-analysis: + needs: build-sentry-native name: Trim analysis runs-on: macos-15 @@ -205,7 +230,7 @@ jobs: submodules: recursive fetch-depth: 2 # default is 1 and codecov needs > 1 - # We use macOS for the final publishing build so we get all the iOS/macCatalyst targets in the packages + # We use macOS for the final publishing build so we get all the iOS/Mac Catalyst targets in the packages - name: Set Environment Variables run: echo "CI_PUBLISHING_BUILD=true" >> $GITHUB_ENV diff --git a/CHANGELOG.md b/CHANGELOG.md index 23385ed7ae..50b12690c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Features - .NET MAUI integration with CommunityToolkit.Mvvm Async Relay Commands can now be auto spanned with the new package Sentry.Maui.CommunityToolkit.Mvvm ([#4125](https://github.com/getsentry/sentry-dotnet/pull/4125)) +- Support for Windows ARM64 with Native AOT ([#4187](https://github.com/getsentry/sentry-dotnet/pull/4187)) ### Dependencies diff --git a/Sentry-CI-Build-Windows-arm64.slnf b/Sentry-CI-Build-Windows-arm64.slnf new file mode 100644 index 0000000000..c1f6bd735d --- /dev/null +++ b/Sentry-CI-Build-Windows-arm64.slnf @@ -0,0 +1,81 @@ +{ + "solution": { + "path": "Sentry.sln", + "projects": [ + "benchmarks\\Sentry.Benchmarks\\Sentry.Benchmarks.csproj", + "modules\\perfview\\src\\FastSerialization\\FastSerialization.csproj", + "modules\\perfview\\src\\TraceEvent\\TraceEvent.csproj", + "samples\\Sentry.Samples.AspNetCore.Basic\\Sentry.Samples.AspNetCore.Basic.csproj", + "samples\\Sentry.Samples.AspNetCore.Blazor.Server\\Sentry.Samples.AspNetCore.Blazor.Server.csproj", + "samples\\Sentry.Samples.AspNetCore.Blazor.Wasm\\Sentry.Samples.AspNetCore.Blazor.Wasm.csproj", + "samples\\Sentry.Samples.AspNetCore.Grpc\\Sentry.Samples.AspNetCore.Grpc.csproj", + "samples\\Sentry.Samples.AspNetCore.Mvc\\Sentry.Samples.AspNetCore.Mvc.csproj", + "samples\\Sentry.Samples.AspNetCore.Serilog\\Sentry.Samples.AspNetCore.Serilog.csproj", + "samples\\Sentry.Samples.AspNetCore.WebAPI.Profiling\\Sentry.Samples.AspNetCore.WebAPI.Profiling.csproj", + "samples\\Sentry.Samples.Aws.Lambda.AspNetCoreServer\\Sentry.Samples.Aws.Lambda.AspNetCoreServer.csproj", + "samples\\Sentry.Samples.Azure.Functions.Worker\\Sentry.Samples.Azure.Functions.Worker.csproj", + "samples\\Sentry.Samples.Console.Basic\\Sentry.Samples.Console.Basic.csproj", + "samples\\Sentry.Samples.Console.Customized\\Sentry.Samples.Console.Customized.csproj", + "samples\\Sentry.Samples.Console.HeapDump\\Sentry.Samples.Console.HeapDump.csproj", + "samples\\Sentry.Samples.Console.Native\\Sentry.Samples.Console.Native.csproj", + "samples\\Sentry.Samples.Console.Profiling\\Sentry.Samples.Console.Profiling.csproj", + "samples\\Sentry.Samples.EntityFramework\\Sentry.Samples.EntityFramework.csproj", + "samples\\Sentry.Samples.GenericHost\\Sentry.Samples.GenericHost.csproj", + "samples\\Sentry.Samples.Google.Cloud.Functions\\Sentry.Samples.Google.Cloud.Functions.csproj", + "samples\\Sentry.Samples.GraphQL.Client.Http\\Sentry.Samples.GraphQL.Client.Http.csproj", + "samples\\Sentry.Samples.GraphQL.Server\\Sentry.Samples.GraphQL.Server.csproj", + "samples\\Sentry.Samples.Hangfire\\Sentry.Samples.Hangfire.csproj", + "samples\\Sentry.Samples.Log4Net\\Sentry.Samples.Log4Net.csproj", + "samples\\Sentry.Samples.Maui\\Sentry.Samples.Maui.csproj", + "samples\\Sentry.Samples.ME.Logging\\Sentry.Samples.ME.Logging.csproj", + "samples\\Sentry.Samples.NLog\\Sentry.Samples.NLog.csproj", + "samples\\Sentry.Samples.OpenTelemetry.AspNetCore\\Sentry.Samples.OpenTelemetry.AspNetCore.csproj", + "samples\\Sentry.Samples.OpenTelemetry.Console\\Sentry.Samples.OpenTelemetry.Console.csproj", + "samples\\Sentry.Samples.Serilog\\Sentry.Samples.Serilog.csproj", + "src\\Sentry.Analyzers\\Sentry.Analyzers.csproj", + "src\\Sentry.Android.AssemblyReader\\Sentry.Android.AssemblyReader.csproj", + "src\\Sentry.AspNet\\Sentry.AspNet.csproj", + "src\\Sentry.AspNetCore.Blazor.WebAssembly\\Sentry.AspNetCore.Blazor.WebAssembly.csproj", + "src\\Sentry.AspNetCore.Grpc\\Sentry.AspNetCore.Grpc.csproj", + "src\\Sentry.AspNetCore\\Sentry.AspNetCore.csproj", + "src\\Sentry.Azure.Functions.Worker\\Sentry.Azure.Functions.Worker.csproj", + "src\\Sentry.Bindings.Android\\Sentry.Bindings.Android.csproj", + "src\\Sentry.DiagnosticSource\\Sentry.DiagnosticSource.csproj", + "src\\Sentry.EntityFramework\\Sentry.EntityFramework.csproj", + "src\\Sentry.Extensions.Logging\\Sentry.Extensions.Logging.csproj", + "src\\Sentry.Google.Cloud.Functions\\Sentry.Google.Cloud.Functions.csproj", + "src\\Sentry.Hangfire\\Sentry.Hangfire.csproj", + "src\\Sentry.Log4Net\\Sentry.Log4Net.csproj", + "src\\Sentry.Maui.CommunityToolkit.Mvvm\\Sentry.Maui.CommunityToolkit.Mvvm.csproj", + "src\\Sentry.Maui\\Sentry.Maui.csproj", + "src\\Sentry.NLog\\Sentry.NLog.csproj", + "src\\Sentry.OpenTelemetry\\Sentry.OpenTelemetry.csproj", + "src\\Sentry.Profiling\\Sentry.Profiling.csproj", + "src\\Sentry.Serilog\\Sentry.Serilog.csproj", + "src\\Sentry.SourceGenerators\\Sentry.SourceGenerators.csproj", + "src\\Sentry\\Sentry.csproj", + "test\\Sentry.Analyzers.Tests\\Sentry.Analyzers.Tests.csproj", + "test\\Sentry.Android.AssemblyReader.Tests\\Sentry.Android.AssemblyReader.Tests.csproj", + "test\\Sentry.AspNet.Tests\\Sentry.AspNet.Tests.csproj", + "test\\Sentry.AspNetCore.Grpc.Tests\\Sentry.AspNetCore.Grpc.Tests.csproj", + "test\\Sentry.AspNetCore.Tests\\Sentry.AspNetCore.Tests.csproj", + "test\\Sentry.AspNetCore.TestUtils\\Sentry.AspNetCore.TestUtils.csproj", + "test\\Sentry.Azure.Functions.Worker.Tests\\Sentry.Azure.Functions.Worker.Tests.csproj", + "test\\Sentry.Extensions.Logging.Tests\\Sentry.Extensions.Logging.Tests.csproj", + "test\\Sentry.Google.Cloud.Functions.Tests\\Sentry.Google.Cloud.Functions.Tests.csproj", + "test\\Sentry.Hangfire.Tests\\Sentry.Hangfire.Tests.csproj", + "test\\Sentry.Log4Net.Tests\\Sentry.Log4Net.Tests.csproj", + "test\\Sentry.Maui.CommunityToolkit.Mvvm.Tests\\Sentry.Maui.CommunityToolkit.Mvvm.Tests.csproj", + "test\\Sentry.Maui.Tests\\Sentry.Maui.Tests.csproj", + "test\\Sentry.NLog.Tests\\Sentry.NLog.Tests.csproj", + "test\\Sentry.OpenTelemetry.Tests\\Sentry.OpenTelemetry.Tests.csproj", + "test\\Sentry.Profiling.Tests\\Sentry.Profiling.Tests.csproj", + "test\\Sentry.Serilog.Tests\\Sentry.Serilog.Tests.csproj", + "test\\Sentry.SourceGenerators.Tests\\Sentry.SourceGenerators.Tests.csproj", + "test\\Sentry.Testing.CrashableApp\\Sentry.Testing.CrashableApp.csproj", + "test\\Sentry.Testing\\Sentry.Testing.csproj", + "test\\Sentry.Tests\\Sentry.Tests.csproj", + "test\\SingleFileTestApp\\SingleFileTestApp.csproj" + ] + } +} diff --git a/integration-test/runtime.Tests.ps1 b/integration-test/runtime.Tests.ps1 index 3c66524006..81f75fe245 100644 --- a/integration-test/runtime.Tests.ps1 +++ b/integration-test/runtime.Tests.ps1 @@ -49,7 +49,14 @@ internal class FakeTransport : ITransport } elseif ($IsWindows) { - return "./console-app/bin/Release/$framework/win-x64/publish/console-app.exe" + if ("Arm64".Equals([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture.ToString())) + { + return "./console-app/bin/Release/$framework/win-arm64/publish/console-app.exe" + } + else + { + return "./console-app/bin/Release/$framework/win-x64/publish/console-app.exe" + } } else { diff --git a/scripts/build-sentry-native.ps1 b/scripts/build-sentry-native.ps1 index fc9d41002d..901399033d 100644 --- a/scripts/build-sentry-native.ps1 +++ b/scripts/build-sentry-native.ps1 @@ -21,11 +21,19 @@ try } elseif ($IsWindows) { - $outDir += '/win-x64' $additionalArgs += @('-C', 'src/Sentry/Platforms/Native/windows-config.cmake') $actualBuildDir = "$buildDir/RelWithDebInfo" $libPrefix = '' $libExtension = '.lib' + + if ("Arm64".Equals([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture.ToString())) + { + $outDir += '/win-arm64' + } + else + { + $outDir += '/win-x64' + } } elseif ($IsLinux) { diff --git a/scripts/generate-solution-filters-config.yaml b/scripts/generate-solution-filters-config.yaml index b4cf392ed6..750b22c095 100644 --- a/scripts/generate-solution-filters-config.yaml +++ b/scripts/generate-solution-filters-config.yaml @@ -83,6 +83,29 @@ filterConfigs: - "**/*Sentry.Samples.Android.csproj" - "**/*OpenTelemetry.AspNet.csproj" + - outputPath: Sentry-CI-Build-Windows-arm64.slnf + include: + groups: + - "allProjects" + patterns: + - "modules/perfview/**/TraceEvent.csproj" + - "modules/perfview/**/FastSerialization.csproj" + exclude: + groups: + - "macOnly" + - "artefacts" + - "trimTests" + patterns: + - "**/*AndroidTestApp.csproj" + - "**/*DeviceTests*.csproj" + - "**/*Sentry.Maui.Device.TestApp.csproj" + - "**/*Sentry.Samples.Android.csproj" + - "**/*OpenTelemetry.AspNet.csproj" + # Depends on LocalDb or SQLitePCL which are x64 + - "**/*Sentry.DiagnosticSource.IntegrationTests.csproj" + - "**/*Sentry.DiagnosticSource.Tests.csproj" + - "**/*Sentry.EntityFramework.Tests.csproj" + - outputPath: Sentry-CI-CodeQL.slnf include: groups: diff --git a/src/Sentry/Platforms/Native/Sentry.Native.targets b/src/Sentry/Platforms/Native/Sentry.Native.targets index a69113be5e..a03d405f27 100644 --- a/src/Sentry/Platforms/Native/Sentry.Native.targets +++ b/src/Sentry/Platforms/Native/Sentry.Native.targets @@ -9,11 +9,14 @@ win-x64 $(SentryNativeOutputDirectory)$(NativeLibRelativePath-win-x64)\ + win-arm64 + $(SentryNativeOutputDirectory)$(NativeLibRelativePath-win-arm64)\ linux-x64 $(SentryNativeOutputDirectory)$(NativeLibRelativePath-linux-x64)\ osx $(SentryNativeOutputDirectory)$(NativeLibRelativePath-osx)\ - $(SentryNativeOutputDirectory-win-x64)$(SentryNativeLibraryName).lib + $(SentryNativeOutputDirectory-win-x64)lib$(SentryNativeLibraryName).lib + $(SentryNativeOutputDirectory-win-arm64)lib$(SentryNativeLibraryName).lib $(SentryNativeOutputDirectory-linux-x64)lib$(SentryNativeLibraryName).a $(SentryNativeOutputDirectory-osx)lib$(SentryNativeLibraryName).a @@ -25,13 +28,20 @@ - + true \sentry-native\$(NativeLibRelativePath-win-x64) + + + true + \sentry-native\$(NativeLibRelativePath-win-arm64) + + + true diff --git a/src/Sentry/Platforms/Native/buildTransitive/Sentry.Native.targets b/src/Sentry/Platforms/Native/buildTransitive/Sentry.Native.targets index 5ab0088570..7b3e800790 100644 --- a/src/Sentry/Platforms/Native/buildTransitive/Sentry.Native.targets +++ b/src/Sentry/Platforms/Native/buildTransitive/Sentry.Native.targets @@ -25,9 +25,9 @@ false - + - +