diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 31356e28de..6de920aae1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,13 +18,13 @@ jobs: fail-fast: false matrix: include: - - os: ubuntu-22.04 # Pin ubuntu to ensure mono is installed - - os: ubuntu-22.04-arm - target: Linux-arm64 - - os: ubuntu-latest - target: Linux-musl - container: ghcr.io/getsentry/sentry-dotnet-alpine:3.21 - - os: macos-15 # Pin macos to get the version of Xcode that we need: https://github.com/actions/runner-images/issues/10703 + # - os: ubuntu-22.04 # Pin ubuntu to ensure mono is installed + # - os: ubuntu-22.04-arm + # target: Linux-arm64 + # - os: ubuntu-latest + # target: Linux-musl + # container: ghcr.io/getsentry/sentry-dotnet-alpine:3.21 + # - 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 @@ -45,7 +45,9 @@ jobs: - uses: actions/cache@v4 id: cache with: - path: src/Sentry/Platforms/Native/sentry-native + path: | + src/Sentry/Platforms/Native/sentry-native + src/Sentry/Platforms/Native/runtimes key: sentry-native-${{ matrix.target || runner.os }}-${{ hashFiles('scripts/build-sentry-native.ps1') }}-${{ hashFiles('.git/modules/modules/sentry-native/HEAD') }} enableCrossOsArchive: true @@ -67,14 +69,14 @@ jobs: fail-fast: false matrix: include: - - os: ubuntu-22.04 # Pin ubuntu to ensure mono is installed - target: Linux - - os: ubuntu-22.04-arm - target: Linux-arm64 - - os: ubuntu-latest - target: Linux-musl - container: ghcr.io/getsentry/sentry-dotnet-alpine:3.21 - - os: macos-15 # Pin macos to get the version of Xcode that we need: https://github.com/actions/runner-images/issues/10703 + # - os: ubuntu-22.04 # Pin ubuntu to ensure mono is installed + # target: Linux + # - os: ubuntu-22.04-arm + # target: Linux-arm64 + # - os: ubuntu-latest + # target: Linux-musl + # container: ghcr.io/getsentry/sentry-dotnet-alpine:3.21 + # - 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 @@ -138,7 +140,9 @@ jobs: 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 + path: | + src/Sentry/Platforms/Native/sentry-native + src/Sentry/Platforms/Native/runtimes key: sentry-native-Windows-${{ hashFiles('scripts/build-sentry-native.ps1') }}-${{ hashFiles('.git/modules/modules/sentry-native/HEAD') }} fail-on-cache-miss: true enableCrossOsArchive: true @@ -147,7 +151,9 @@ jobs: 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 + path: | + src/Sentry/Platforms/Native/sentry-native + src/Sentry/Platforms/Native/runtimes 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 @@ -171,13 +177,15 @@ jobs: path: build.binlog - name: Test + if: false 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 + if: false uses: codecov/codecov-action@18283e04ce6e62d37312384ff67231eb8fd56d24 - name: Upload build and test outputs - if: failure() + if: ${{ false && failure() }} uses: actions/upload-artifact@v4 with: name: ${{ matrix.target || runner.os }}-verify-test-results @@ -186,6 +194,10 @@ jobs: - name: Create NuGet Packages run: dotnet pack Sentry-CI-Build-${{ matrix.target || runner.os }}.slnf -c Release --no-build --nologo + - name: Inspect NuGet Packages + shell: bash + run: unzip -l src/Sentry/bin/Release/Sentry.*.nupkg + - name: Archive NuGet Packages if: env.CI_PUBLISHING_BUILD == 'true' uses: actions/upload-artifact@v4 @@ -218,11 +230,52 @@ jobs: with: path: integration-test + msbuild: + needs: build-sentry-native + name: MSBuild + runs-on: windows-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Download sentry-native (Windows) + uses: actions/cache/restore@v4 + with: + path: src/Sentry/Platforms/Native/sentry-native + key: sentry-native-Windows-${{ hashFiles('scripts/build-sentry-native.ps1') }}-${{ hashFiles('.git/modules/modules/sentry-native/HEAD') }} + fail-on-cache-miss: true + enableCrossOsArchive: true + + - name: Setup Environment + uses: ./.github/actions/environment + + - name: Build Native Dependencies + uses: ./.github/actions/buildnative + + - name: Setup MSBuild + uses: microsoft/setup-msbuild@6fb02220983dee41ce7ae257b6f4d8f9bf5ed4ce # v2 + + - name: Run MSBuild + id: msbuild + run: msbuild Sentry-CI-Build-Windows.slnf -t:Restore,Build -p:Configuration=Release --nologo -v:minimal -flp:logfile=msbuild.log -p:CopyLocalLockFileAssemblies=true -bl:msbuild.binlog + + - name: Upload logs + if: ${{ steps.msbuild.outcome != 'skipped' }} + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.target || runner.os }}-msbuild-logs + path: | + msbuild.log + msbuild.binlog trim-analysis: needs: build-sentry-native name: Trim analysis runs-on: macos-15 + if: false steps: - name: Checkout diff --git a/.github/workflows/device-tests-android.yml b/.github/workflows/device-tests-android.yml index f7192e1854..362a98bbc6 100644 --- a/.github/workflows/device-tests-android.yml +++ b/.github/workflows/device-tests-android.yml @@ -11,6 +11,7 @@ on: jobs: build: + if: false name: Build (${{ matrix.tfm }}) runs-on: ubuntu-latest strategy: diff --git a/.github/workflows/device-tests-ios.yml b/.github/workflows/device-tests-ios.yml index 3474a210c5..acea14ee5a 100644 --- a/.github/workflows/device-tests-ios.yml +++ b/.github/workflows/device-tests-ios.yml @@ -11,6 +11,7 @@ on: jobs: ios-tests: + if: false runs-on: macos-15 env: DOTNET_CLI_TELEMETRY_OPTOUT: 1 diff --git a/Sentry-CI-Build-Windows-arm64.slnf b/Sentry-CI-Build-Windows-arm64.slnf index c1f6bd735d..88b5ce7c82 100644 --- a/Sentry-CI-Build-Windows-arm64.slnf +++ b/Sentry-CI-Build-Windows-arm64.slnf @@ -75,7 +75,8 @@ "test\\Sentry.Testing.CrashableApp\\Sentry.Testing.CrashableApp.csproj", "test\\Sentry.Testing\\Sentry.Testing.csproj", "test\\Sentry.Tests\\Sentry.Tests.csproj", - "test\\SingleFileTestApp\\SingleFileTestApp.csproj" + "test\\SingleFileTestApp\\SingleFileTestApp.csproj", + "test\\WinUITestApp\\WinUITestApp.csproj" ] } } diff --git a/Sentry-CI-Build-Windows.slnf b/Sentry-CI-Build-Windows.slnf index d5960f2212..722205073f 100644 --- a/Sentry-CI-Build-Windows.slnf +++ b/Sentry-CI-Build-Windows.slnf @@ -78,7 +78,8 @@ "test\\Sentry.Testing.CrashableApp\\Sentry.Testing.CrashableApp.csproj", "test\\Sentry.Testing\\Sentry.Testing.csproj", "test\\Sentry.Tests\\Sentry.Tests.csproj", - "test\\SingleFileTestApp\\SingleFileTestApp.csproj" + "test\\SingleFileTestApp\\SingleFileTestApp.csproj", + "test\\WinUITestApp\\WinUITestApp.csproj" ] } } diff --git a/Sentry.sln b/Sentry.sln index 3730377a46..b92ef88823 100644 --- a/Sentry.sln +++ b/Sentry.sln @@ -209,6 +209,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sentry.SourceGenerators.Tes EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sentry.Maui.CommunityToolkit.Mvvm.Tests", "test\Sentry.Maui.CommunityToolkit.Mvvm.Tests\Sentry.Maui.CommunityToolkit.Mvvm.Tests.csproj", "{ADC91A84-6054-42EC-8241-0D717E4C7194}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinUITestApp", "test\WinUITestApp\WinUITestApp.csproj", "{5256EFC6-D4F6-48C8-AB65-B8F2651719B1}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU diff --git a/scripts/build-sentry-native.ps1 b/scripts/build-sentry-native.ps1 index 8e7361901d..d6cb3d96da 100644 --- a/scripts/build-sentry-native.ps1 +++ b/scripts/build-sentry-native.ps1 @@ -2,12 +2,13 @@ param([switch] $Clean) Set-StrictMode -Version Latest $ErrorActionPreference = "Stop" -Push-Location $PSScriptRoot/.. -try +function Build-SentryNative { + param([switch] $Shared) + $submodule = 'modules/sentry-native' $outDir = 'src/Sentry/Platforms/Native/sentry-native' - $buildDir = "$submodule/build" + $buildDir = if ($Shared) { "$submodule/build-shared" } else { "$submodule/build" } $actualBuildDir = $buildDir $additionalArgs = @() @@ -24,15 +25,15 @@ try $additionalArgs += @('-C', 'src/Sentry/Platforms/Native/windows-config.cmake') $actualBuildDir = "$buildDir/RelWithDebInfo" $libPrefix = '' - $libExtension = '.lib' + $libExtension = if ($Shared) { '.dll' } else { '.lib' } if ("Arm64".Equals([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture.ToString())) { - $outDir += '/win-arm64' + $outDir += if ($Shared) { '/../runtimes/win-arm64/native' } else { '/win-arm64' } } else { - $outDir += '/win-x64' + $outDir += if ($Shared) { '/../runtimes/win-x64/native' } else { '/win-x64' } } } elseif ($IsLinux) @@ -62,12 +63,16 @@ try Remove-Item -Recurse -Force -ErrorAction SilentlyContinue $buildDir } + if (-not $Shared) + { + $additionalArgs += @('-D', 'SENTRY_BUILD_SHARED_LIBS=0') + } + cmake ` -S $submodule ` -B $buildDir ` -D CMAKE_BUILD_TYPE=RelWithDebInfo ` -D SENTRY_SDK_NAME=sentry.native.dotnet ` - -D SENTRY_BUILD_SHARED_LIBS=0 ` -D SENTRY_BACKEND=inproc ` -D SENTRY_TRANSPORT=none ` $additionalArgs @@ -90,6 +95,16 @@ try # Touch the file to mark it as up-to-date for MSBuild (Get-Item $outFile).LastWriteTime = Get-Date } + +Push-Location $PSScriptRoot/.. +try +{ + Build-SentryNative + if ($IsWindows) + { + Build-SentryNative -Shared + } +} finally { Pop-Location diff --git a/scripts/generate-solution-filters-config.yaml b/scripts/generate-solution-filters-config.yaml index 1cfee815c1..87b6e0c9f5 100644 --- a/scripts/generate-solution-filters-config.yaml +++ b/scripts/generate-solution-filters-config.yaml @@ -25,6 +25,7 @@ groupConfigs: # .NET Framework projects - "**/*.AspNet.csproj" - "**/*.AspNet.Tests.csproj" + - "**/*WinUITestApp.csproj" artefacts: # Any projects in the obj or bin directories - "**/obj/**/*.csproj" @@ -95,6 +96,7 @@ filterConfigs: - "**/*AndroidTestApp.csproj" - "**/*DeviceTests*.csproj" - "**/*.AspNet.Tests.csproj" + - "**/*WinUITestApp.csproj" - outputPath: Sentry-CI-Build-Windows.slnf include: @@ -255,6 +257,7 @@ filterConfigs: - "**/*Android*.csproj" - "**/*Ios*.csproj" - "**/*Maui*.csproj" + - "**/*WinUI*.csproj" - outputPath: SentryNoSamples.slnf include: diff --git a/src/Sentry/Platforms/Native/.gitignore b/src/Sentry/Platforms/Native/.gitignore index adf28a93fc..6e314cab61 100644 --- a/src/Sentry/Platforms/Native/.gitignore +++ b/src/Sentry/Platforms/Native/.gitignore @@ -1 +1,2 @@ sentry-native +runtimes diff --git a/src/Sentry/Platforms/Native/Sentry.Native.targets b/src/Sentry/Platforms/Native/Sentry.Native.targets index befa26d123..4004df659d 100644 --- a/src/Sentry/Platforms/Native/Sentry.Native.targets +++ b/src/Sentry/Platforms/Native/Sentry.Native.targets @@ -6,6 +6,7 @@ ../../scripts/build-sentry-native.ps1 ../../.git/modules/modules/sentry-native/HEAD;$(MSBuildThisFileDirectory)Sentry.Native.targets;$(SentryNativeBuildScript) $(MSBuildThisFileDirectory)sentry-native\ + $(MSBuildThisFileDirectory)runtimes\ win-x64 $(SentryNativeOutputDirectory)$(NativeLibRelativePath-win-x64)\ @@ -19,8 +20,14 @@ $(SentryNativeOutputDirectory)$(NativeLibRelativePath-linux-arm64)\ osx $(SentryNativeOutputDirectory)$(NativeLibRelativePath-osx)\ - $(SentryNativeOutputDirectory-win-x64)lib$(SentryNativeLibraryName).lib - $(SentryNativeOutputDirectory-win-arm64)lib$(SentryNativeLibraryName).lib + + $(SentryNativeOutputDirectory-win-x64)lib$(SentryNativeLibraryName).lib + $(SentryNativeRuntimeDirectory)win-x64\native\lib$(SentryNativeLibraryName).dll + + + $(SentryNativeOutputDirectory-win-arm64)lib$(SentryNativeLibraryName).lib + $(SentryNativeRuntimeDirectory)win-arm64\native\lib$(SentryNativeLibraryName).dll + $(SentryNativeOutputDirectory-linux-x64)lib$(SentryNativeLibraryName).a $(SentryNativeOutputDirectory-linux-musl-x64)lib$(SentryNativeLibraryName).a $(SentryNativeOutputDirectory-linux-arm64)lib$(SentryNativeLibraryName).a @@ -34,35 +41,49 @@ - + true \sentry-native\$(NativeLibRelativePath-win-x64) + + true + \runtimes\win-x64\native + %(Filename)%(Extension) + PreserveNewest + - + true \sentry-native\$(NativeLibRelativePath-win-arm64) + + true + \runtimes\win-arm64\native + %(Filename)%(Extension) + PreserveNewest + - + true \sentry-native\$(NativeLibRelativePath-linux-x64) - + true \sentry-native\$(NativeLibRelativePath-linux-musl-x64) - + true \sentry-native\$(NativeLibRelativePath-linux-arm64) @@ -79,7 +100,9 @@ + + + + + + + + + + + + + + + diff --git a/test/WinUITestApp/App.xaml.cs b/test/WinUITestApp/App.xaml.cs new file mode 100644 index 0000000000..d35890514b --- /dev/null +++ b/test/WinUITestApp/App.xaml.cs @@ -0,0 +1,44 @@ +using System.Security; +using Microsoft.UI.Xaml; +using Sentry; +using Sentry.Protocol; + +namespace winui_app +{ + public partial class App : Application + { + private Window? _window; + + public App() + { + SentrySdk.Init(options => + { + options.Dsn = "http://key@127.0.0.1:9999/123"; + options.Debug = true; + options.IsGlobalModeEnabled = true; + }); + UnhandledException += OnUnhandledException; + + InitializeComponent(); + } + + protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args) + { + _window = new MainWindow(); + _window.Activate(); + } + + [SecurityCritical] + private void OnUnhandledException(object sender, Microsoft.UI.Xaml.UnhandledExceptionEventArgs e) + { + var exception = e.Exception; + if (exception != null) + { + exception.Data[Mechanism.HandledKey] = false; + exception.Data[Mechanism.MechanismKey] = "Application.UnhandledException"; + SentrySdk.CaptureException(exception); + SentrySdk.FlushAsync(TimeSpan.FromSeconds(2)).GetAwaiter().GetResult(); + } + } + } +} diff --git a/test/WinUITestApp/Assets/sentry-wordmark-dark-300x90.png b/test/WinUITestApp/Assets/sentry-wordmark-dark-300x90.png new file mode 100644 index 0000000000..a11de3b60f Binary files /dev/null and b/test/WinUITestApp/Assets/sentry-wordmark-dark-300x90.png differ diff --git a/test/WinUITestApp/Assets/sentry-wordmark-light-300x90.png b/test/WinUITestApp/Assets/sentry-wordmark-light-300x90.png new file mode 100644 index 0000000000..e9077036b4 Binary files /dev/null and b/test/WinUITestApp/Assets/sentry-wordmark-light-300x90.png differ diff --git a/test/WinUITestApp/MainWindow.xaml b/test/WinUITestApp/MainWindow.xaml new file mode 100644 index 0000000000..061a983cf3 --- /dev/null +++ b/test/WinUITestApp/MainWindow.xaml @@ -0,0 +1,34 @@ + + + + + + + + + + + + +