From 19b741fa25fe97c85eeaa7498fda304fd8f4120b Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Thu, 19 Jun 2025 17:25:00 +0200 Subject: [PATCH 01/23] ci: use safer non-cone-mode sparse checkout for integration tests Without Directory.Build.props, nuget.config etc. --- .github/workflows/build.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 31356e28de..c94e2bc7e8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -197,14 +197,16 @@ jobs: src/**/Release/*.snupkg - name: Sparse checkout - if: env.CI_PUBLISHING_BUILD == 'true' uses: actions/checkout@v4 with: # We only check out what is absolutely necessary to reduce a chance of local files impacting - # integration tests, e.g. Directory.Build.props, nuget.config, ... + # integration tests sparse-checkout: | integration-test .github + # Disable cone mode to avoid individual top-level files being checkout out + # e.g. Directory.Build.props, nuget.config, ... + sparse-checkout-cone-mode: false - name: Fetch NuGet Packages if: env.CI_PUBLISHING_BUILD == 'true' From 2a82dff38dcc802ce41809c0a2a8d59629978a11 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Thu, 19 Jun 2025 17:40:53 +0200 Subject: [PATCH 02/23] top-level Directory.Build.props is required the integration test reads sentry version from there --- .github/workflows/build.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c94e2bc7e8..1b4c47f419 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -202,10 +202,11 @@ jobs: # We only check out what is absolutely necessary to reduce a chance of local files impacting # integration tests sparse-checkout: | + Directory.Build.props integration-test .github # Disable cone mode to avoid individual top-level files being checkout out - # e.g. Directory.Build.props, nuget.config, ... + # e.g. nuget.config, ... sparse-checkout-cone-mode: false - name: Fetch NuGet Packages From 5be84902bfb0eb489ca4f28570794dc682c09b76 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Thu, 19 Jun 2025 18:18:46 +0200 Subject: [PATCH 03/23] retain src/**/Release/*.(s)nupkg --- .github/workflows/build.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1b4c47f419..b1b0ffc1dd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -208,6 +208,8 @@ jobs: # Disable cone mode to avoid individual top-level files being checkout out # e.g. nuget.config, ... sparse-checkout-cone-mode: false + # Retain src/**/Release/*.(s)nupkg + clean: false - name: Fetch NuGet Packages if: env.CI_PUBLISHING_BUILD == 'true' From 9c8f845976fd6694b89493006b835df4e83f1b10 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Thu, 19 Jun 2025 19:12:47 +0200 Subject: [PATCH 04/23] dump preprocessed msbuild for integration test --- .github/workflows/build.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b1b0ffc1dd..67d661b412 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -218,6 +218,17 @@ jobs: name: ${{ github.sha }} path: src + - name: Dump MSBuild + run: | + dotnet msbuild console-app.csproj -pp:console-app.msbuild + working-directory: integration-test/console-app + + - name: Upload MSBuild + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.target || runner.os }}-msbuild + path: integration-test/console-app/console-app.msbuild + - name: Integration test uses: getsentry/github-workflows/sentry-cli/integration-test/@v2 with: From 2c8415793a658f2a81e8de6889851d74e1f7c6f2 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Thu, 19 Jun 2025 19:13:37 +0200 Subject: [PATCH 05/23] temp skip tests to speed up things --- .github/workflows/build.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 67d661b412..d27266901d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -170,11 +170,11 @@ jobs: name: ${{ matrix.target || runner.os }}-build-logs path: build.binlog - - name: Test - 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: Test + # 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@18283e04ce6e62d37312384ff67231eb8fd56d24 + # - name: Upload code coverage + # uses: codecov/codecov-action@18283e04ce6e62d37312384ff67231eb8fd56d24 - name: Upload build and test outputs if: failure() From e900d6c8a208ecf9a53d4005ee36b2ab794c13f5 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Thu, 19 Jun 2025 19:23:15 +0200 Subject: [PATCH 06/23] reorder --- .github/workflows/build.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d27266901d..af826f0854 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -218,6 +218,11 @@ jobs: name: ${{ github.sha }} path: src + - name: Integration test + uses: getsentry/github-workflows/sentry-cli/integration-test/@v2 + with: + path: integration-test + - name: Dump MSBuild run: | dotnet msbuild console-app.csproj -pp:console-app.msbuild @@ -229,11 +234,6 @@ jobs: name: ${{ matrix.target || runner.os }}-msbuild path: integration-test/console-app/console-app.msbuild - - name: Integration test - uses: getsentry/github-workflows/sentry-cli/integration-test/@v2 - with: - path: integration-test - trim-analysis: needs: build-sentry-native From e1b1b72ef6b6217b63669618a2f119188e1f652a Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Thu, 19 Jun 2025 20:24:27 +0200 Subject: [PATCH 07/23] diag Sentry.Native.targets --- .../Native/buildTransitive/Sentry.Native.targets | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Sentry/Platforms/Native/buildTransitive/Sentry.Native.targets b/src/Sentry/Platforms/Native/buildTransitive/Sentry.Native.targets index 8dd9ec60ae..aea662b3e4 100644 --- a/src/Sentry/Platforms/Native/buildTransitive/Sentry.Native.targets +++ b/src/Sentry/Platforms/Native/buildTransitive/Sentry.Native.targets @@ -50,4 +50,13 @@ + + + + + + + + + From 090070f244b59b74bcbb0131ba337e0444ae5c0f Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Thu, 19 Jun 2025 20:27:06 +0200 Subject: [PATCH 08/23] try binlog --- .github/workflows/build.yml | 9 ++------- integration-test/runtime.Tests.ps1 | 1 + 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index af826f0854..e6a3a2bb0d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -223,16 +223,11 @@ jobs: with: path: integration-test - - name: Dump MSBuild - run: | - dotnet msbuild console-app.csproj -pp:console-app.msbuild - working-directory: integration-test/console-app - - name: Upload MSBuild uses: actions/upload-artifact@v4 with: - name: ${{ matrix.target || runner.os }}-msbuild - path: integration-test/console-app/console-app.msbuild + name: ${{ matrix.target || runner.os }}-console-app.binlog + path: integration-test/console-app/console-app.binlog trim-analysis: diff --git a/integration-test/runtime.Tests.ps1 b/integration-test/runtime.Tests.ps1 index c8a0a55e15..867b673ce1 100644 --- a/integration-test/runtime.Tests.ps1 +++ b/integration-test/runtime.Tests.ps1 @@ -78,6 +78,7 @@ internal class FakeTransport : ITransport function publishConsoleApp([bool]$SentryNative = $true) { dotnet publish console-app ` + -bl:console-app.binlog ` -c Release ` --nologo ` --framework $framework ` From 5484bc8bc6165107f555833ed432ddb202da39b2 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Thu, 19 Jun 2025 20:45:02 +0200 Subject: [PATCH 09/23] fix binlog path --- .github/workflows/build.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e6a3a2bb0d..fcc13ddbe3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -227,7 +227,8 @@ jobs: uses: actions/upload-artifact@v4 with: name: ${{ matrix.target || runner.os }}-console-app.binlog - path: integration-test/console-app/console-app.binlog + path: integration-test/console-app.binlog + if-no-files-found: error trim-analysis: From 65ce81c78420fc54e7898286c4a8cddb1a625e05 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Thu, 19 Jun 2025 21:56:54 +0200 Subject: [PATCH 10/23] undo everything --- .github/workflows/build.yml | 24 +++++-------------- integration-test/runtime.Tests.ps1 | 1 - .../buildTransitive/Sentry.Native.targets | 9 ------- 3 files changed, 6 insertions(+), 28 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fcc13ddbe3..31356e28de 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -170,11 +170,11 @@ jobs: name: ${{ matrix.target || runner.os }}-build-logs path: build.binlog - # - name: Test - # 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: Test + 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@18283e04ce6e62d37312384ff67231eb8fd56d24 + - name: Upload code coverage + uses: codecov/codecov-action@18283e04ce6e62d37312384ff67231eb8fd56d24 - name: Upload build and test outputs if: failure() @@ -197,19 +197,14 @@ jobs: src/**/Release/*.snupkg - name: Sparse checkout + if: env.CI_PUBLISHING_BUILD == 'true' uses: actions/checkout@v4 with: # We only check out what is absolutely necessary to reduce a chance of local files impacting - # integration tests + # integration tests, e.g. Directory.Build.props, nuget.config, ... sparse-checkout: | - Directory.Build.props integration-test .github - # Disable cone mode to avoid individual top-level files being checkout out - # e.g. nuget.config, ... - sparse-checkout-cone-mode: false - # Retain src/**/Release/*.(s)nupkg - clean: false - name: Fetch NuGet Packages if: env.CI_PUBLISHING_BUILD == 'true' @@ -223,13 +218,6 @@ jobs: with: path: integration-test - - name: Upload MSBuild - uses: actions/upload-artifact@v4 - with: - name: ${{ matrix.target || runner.os }}-console-app.binlog - path: integration-test/console-app.binlog - if-no-files-found: error - trim-analysis: needs: build-sentry-native diff --git a/integration-test/runtime.Tests.ps1 b/integration-test/runtime.Tests.ps1 index 867b673ce1..c8a0a55e15 100644 --- a/integration-test/runtime.Tests.ps1 +++ b/integration-test/runtime.Tests.ps1 @@ -78,7 +78,6 @@ internal class FakeTransport : ITransport function publishConsoleApp([bool]$SentryNative = $true) { dotnet publish console-app ` - -bl:console-app.binlog ` -c Release ` --nologo ` --framework $framework ` diff --git a/src/Sentry/Platforms/Native/buildTransitive/Sentry.Native.targets b/src/Sentry/Platforms/Native/buildTransitive/Sentry.Native.targets index aea662b3e4..8dd9ec60ae 100644 --- a/src/Sentry/Platforms/Native/buildTransitive/Sentry.Native.targets +++ b/src/Sentry/Platforms/Native/buildTransitive/Sentry.Native.targets @@ -50,13 +50,4 @@ - - - - - - - - - From 199cb8c35ca93868da5280bb19477dcac980bb99 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Thu, 19 Jun 2025 23:02:22 +0200 Subject: [PATCH 11/23] ci: native-aot-docker --- .github/workflows/build.yml | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 31356e28de..36a9ff1b25 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -218,6 +218,43 @@ jobs: with: path: integration-test + native-aot-docker: + needs: build + name: Native AOT in Docker + runs-on: ubuntu-22.04 + + steps: + - name: Fetch NuGet Packages + uses: actions/download-artifact@v4 + with: + name: ${{ github.sha }} + path: src + + - name: Setup Local Source + run: | + mkdir local-packages + cp src/Sentry/bin/Release/Sentry.*.nupkg local-packages/ + dotnet nuget add source $PWD/local-packages --name local-packages + dotnet nuget list source + + - name: Setup Project + run: | + dotnet new console --aot + dotnet add package Sentry --prerelease --source ./local-packages + cat > Program.cs <<'EOF' + SentrySdk.Init(options => + { + options.Dsn = "https://foo@sentry.invalid/42"; + options.Debug = true; + }); + Console.WriteLine("Hello, Sentry!"); + EOF + + - name: Publish Project + run: dotnet publish -p:EnableSdkContainerSupport=true -t:PublishContainer + + - name: Run Docker Container + run: docker run --rm helloworld trim-analysis: needs: build-sentry-native From 6474302cb807fce7174563fd16e8977e66b67717 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Thu, 19 Jun 2025 23:20:50 +0200 Subject: [PATCH 12/23] dotnet 9.0 & name --- .github/workflows/build.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 36a9ff1b25..4be53d74ba 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -224,6 +224,10 @@ jobs: runs-on: ubuntu-22.04 steps: + - uses: actions/setup-dotnet@v4 + with: + dotnet-version: 9.0 + - name: Fetch NuGet Packages uses: actions/download-artifact@v4 with: @@ -239,7 +243,7 @@ jobs: - name: Setup Project run: | - dotnet new console --aot + dotnet new console --aot -n hello-sentry dotnet add package Sentry --prerelease --source ./local-packages cat > Program.cs <<'EOF' SentrySdk.Init(options => @@ -253,9 +257,9 @@ jobs: - name: Publish Project run: dotnet publish -p:EnableSdkContainerSupport=true -t:PublishContainer - - name: Run Docker Container - run: docker run --rm helloworld - + - name: Run Container + run: docker run hello-sentry + trim-analysis: needs: build-sentry-native name: Trim analysis From 09039868f3110d38f2d2fc964e803a580f429def Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Thu, 19 Jun 2025 23:38:05 +0200 Subject: [PATCH 13/23] composite --- .github/actions/testcontainer/action.yml | 37 ++++++++++++++++++++ .github/workflows/build.yml | 44 ++---------------------- 2 files changed, 40 insertions(+), 41 deletions(-) create mode 100644 .github/actions/testcontainer/action.yml diff --git a/.github/actions/testcontainer/action.yml b/.github/actions/testcontainer/action.yml new file mode 100644 index 0000000000..28a5048adc --- /dev/null +++ b/.github/actions/testcontainer/action.yml @@ -0,0 +1,37 @@ +name: Container test +description: Builds a minimal Native AOT app and runs it in a Docker container. +runs: + using: composite + steps: + - name: Setup Local Source + shell: bash + run: | + mkdir /tmp/local-packages + cp ${{github.workspace}}/src/Sentry/bin/Release/Sentry.*.nupkg /tmp/local-packages/ + dotnet nuget add source /tmp/local-packages --name local-packages + dotnet nuget list source + + - name: Setup Project + shell: bash + run: | + dotnet --version + dotnet new console --aot -o /tmp/hello-sentry + cd /tmp/hello-sentry + dotnet add package Sentry --prerelease --source /tmp/local-packages + cat > Program.cs <<'EOF' + SentrySdk.Init(options => + { + options.Dsn = "https://foo@sentry.invalid/42"; + options.Debug = true; + }); + Console.WriteLine("Hello, Sentry!"); + EOF + + - name: Publish Project + shell: bash + run: dotnet publish -p:EnableSdkContainerSupport=true -t:PublishContainer + working-directory: /tmp/hello-sentry + + - name: Run Container + shell: bash + run: docker run hello-sentry diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4be53d74ba..ebe762e4db 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -218,48 +218,10 @@ jobs: with: path: integration-test - native-aot-docker: - needs: build - name: Native AOT in Docker - runs-on: ubuntu-22.04 - - steps: - - uses: actions/setup-dotnet@v4 - with: - dotnet-version: 9.0 - - - name: Fetch NuGet Packages - uses: actions/download-artifact@v4 - with: - name: ${{ github.sha }} - path: src + - name: Container test + if: ${{ runner.os == 'Linux' && !matrix.container }} + uses: ./.github/actions/testcontainer - - name: Setup Local Source - run: | - mkdir local-packages - cp src/Sentry/bin/Release/Sentry.*.nupkg local-packages/ - dotnet nuget add source $PWD/local-packages --name local-packages - dotnet nuget list source - - - name: Setup Project - run: | - dotnet new console --aot -n hello-sentry - dotnet add package Sentry --prerelease --source ./local-packages - cat > Program.cs <<'EOF' - SentrySdk.Init(options => - { - options.Dsn = "https://foo@sentry.invalid/42"; - options.Debug = true; - }); - Console.WriteLine("Hello, Sentry!"); - EOF - - - name: Publish Project - run: dotnet publish -p:EnableSdkContainerSupport=true -t:PublishContainer - - - name: Run Container - run: docker run hello-sentry - trim-analysis: needs: build-sentry-native name: Trim analysis From 1ec3d8cb012b284bb2d27f79a1ceb7c9d1940a9c Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Fri, 20 Jun 2025 00:35:59 +0200 Subject: [PATCH 14/23] test AOT on all platforms --- .github/actions/testcontainer/action.yml | 37 --------------------- .github/workflows/build.yml | 6 ++-- scripts/aot-test.ps1 | 42 ++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 40 deletions(-) delete mode 100644 .github/actions/testcontainer/action.yml create mode 100644 scripts/aot-test.ps1 diff --git a/.github/actions/testcontainer/action.yml b/.github/actions/testcontainer/action.yml deleted file mode 100644 index 28a5048adc..0000000000 --- a/.github/actions/testcontainer/action.yml +++ /dev/null @@ -1,37 +0,0 @@ -name: Container test -description: Builds a minimal Native AOT app and runs it in a Docker container. -runs: - using: composite - steps: - - name: Setup Local Source - shell: bash - run: | - mkdir /tmp/local-packages - cp ${{github.workspace}}/src/Sentry/bin/Release/Sentry.*.nupkg /tmp/local-packages/ - dotnet nuget add source /tmp/local-packages --name local-packages - dotnet nuget list source - - - name: Setup Project - shell: bash - run: | - dotnet --version - dotnet new console --aot -o /tmp/hello-sentry - cd /tmp/hello-sentry - dotnet add package Sentry --prerelease --source /tmp/local-packages - cat > Program.cs <<'EOF' - SentrySdk.Init(options => - { - options.Dsn = "https://foo@sentry.invalid/42"; - options.Debug = true; - }); - Console.WriteLine("Hello, Sentry!"); - EOF - - - name: Publish Project - shell: bash - run: dotnet publish -p:EnableSdkContainerSupport=true -t:PublishContainer - working-directory: /tmp/hello-sentry - - - name: Run Container - shell: bash - run: docker run hello-sentry diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ebe762e4db..70cf4abfe4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -218,9 +218,9 @@ jobs: with: path: integration-test - - name: Container test - if: ${{ runner.os == 'Linux' && !matrix.container }} - uses: ./.github/actions/testcontainer + - name: AOT test + shell: pwsh + run: scripts/aot-test.ps1 trim-analysis: needs: build-sentry-native diff --git a/scripts/aot-test.ps1 b/scripts/aot-test.ps1 new file mode 100644 index 0000000000..898059aa4e --- /dev/null +++ b/scripts/aot-test.ps1 @@ -0,0 +1,42 @@ +$package = Get-ChildItem -Path "$PSScriptRoot/../src/Sentry/bin/Release/Sentry.*.nupkg" -File | Select-Object -First 1 +if (-not $package) { + Write-Error "No NuGet package found in src/Sentry/bin/Release." + exit 1 +} + +$tempDir = Join-Path ([System.IO.Path]::GetTempPath()) ([System.IO.Path]::GetRandomFileName()) +Write-Host "Testing $package in $tempDir" +dotnet --info + +# Setup local NuGet source +$localPackages = Join-Path $tempDir "packages" +New-Item -ItemType Directory -Path $localPackages -Force | Out-Null +Copy-Item $package $localPackages +$localConfig = Join-Path $tempDir "nuget.conf" +Copy-Item $PSScriptRoot/../integration-test/nuget.config $localConfig +dotnet nuget list source --configfile $localConfig + +# Setup test project +Set-Location $tempDir +dotnet new console --aot --name hello-sentry --output . +dotnet add package Sentry --prerelease --source $localPackages +@" +SentrySdk.Init(options => +{ + options.Dsn = "https://foo@sentry.invalid/42"; + options.Debug = true; +}); +Console.WriteLine("Hello, Sentry!"); +"@ | Set-Content Program.cs + +# Test AOT +dotnet publish +$tfm = (Get-ChildItem -Path "bin/Release" -Directory | Select-Object -First 1).Name +$rid = (Get-ChildItem -Path "bin/Release/$tfm" -Directory | Select-Object -First 1).Name +& "bin/Release/$tfm/$rid/publish/hello-sentry" + +# Test Container +if ($IsLinux) { + dotnet publish -p:EnableSdkContainerSupport=true -t:PublishContainer + docker run hello-sentry +} From 49a3f8c545750f2952f60391a9ffb0d9cdbe67a5 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Fri, 20 Jun 2025 11:46:02 +0200 Subject: [PATCH 15/23] check if docker is available --- scripts/aot-test.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/aot-test.ps1 b/scripts/aot-test.ps1 index 898059aa4e..29db291a49 100644 --- a/scripts/aot-test.ps1 +++ b/scripts/aot-test.ps1 @@ -36,7 +36,7 @@ $rid = (Get-ChildItem -Path "bin/Release/$tfm" -Directory | Select-Object -First & "bin/Release/$tfm/$rid/publish/hello-sentry" # Test Container -if ($IsLinux) { +if ($IsLinux -and (Get-Command docker -ErrorAction SilentlyContinue)) { dotnet publish -p:EnableSdkContainerSupport=true -t:PublishContainer docker run hello-sentry } From 51e977850eaef8457ebed8206f7626cf1e3147ba Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Fri, 20 Jun 2025 12:15:59 +0200 Subject: [PATCH 16/23] grouped and detailed output --- scripts/aot-test.ps1 | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/scripts/aot-test.ps1 b/scripts/aot-test.ps1 index 29db291a49..b953c8db47 100644 --- a/scripts/aot-test.ps1 +++ b/scripts/aot-test.ps1 @@ -5,19 +5,23 @@ if (-not $package) { } $tempDir = Join-Path ([System.IO.Path]::GetTempPath()) ([System.IO.Path]::GetRandomFileName()) +New-Item -ItemType Directory -Path $tempDir -Force | Out-Null +Set-Location $tempDir Write-Host "Testing $package in $tempDir" +Write-Host "::group::.NET info" dotnet --info +Write-Host "::endgroup::" -# Setup local NuGet source +Write-Host "::group::Setup local NuGet source" $localPackages = Join-Path $tempDir "packages" New-Item -ItemType Directory -Path $localPackages -Force | Out-Null Copy-Item $package $localPackages $localConfig = Join-Path $tempDir "nuget.conf" Copy-Item $PSScriptRoot/../integration-test/nuget.config $localConfig dotnet nuget list source --configfile $localConfig +Write-Host "::endgroup::" -# Setup test project -Set-Location $tempDir +Write-Host "::group::Create test project" dotnet new console --aot --name hello-sentry --output . dotnet add package Sentry --prerelease --source $localPackages @" @@ -28,15 +32,18 @@ SentrySdk.Init(options => }); Console.WriteLine("Hello, Sentry!"); "@ | Set-Content Program.cs +Write-Host "::endgroup::" -# Test AOT -dotnet publish +Write-Host "::group::Test PublishAot" +dotnet publish -c Release -v:detailed $tfm = (Get-ChildItem -Path "bin/Release" -Directory | Select-Object -First 1).Name $rid = (Get-ChildItem -Path "bin/Release/$tfm" -Directory | Select-Object -First 1).Name & "bin/Release/$tfm/$rid/publish/hello-sentry" +Write-Host "::endgroup::" -# Test Container if ($IsLinux -and (Get-Command docker -ErrorAction SilentlyContinue)) { - dotnet publish -p:EnableSdkContainerSupport=true -t:PublishContainer + Write-Host "::group::Test PublishContainer" + dotnet publish -p:EnableSdkContainerSupport=true -t:PublishContainer -v:detailed docker run hello-sentry + Write-Host "::endgroup::" } From 28d776a0a2fafafcd45b720e3c45c08ecbe2b62b Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Fri, 20 Jun 2025 12:30:58 +0200 Subject: [PATCH 17/23] clean up docker containers --- scripts/aot-test.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/aot-test.ps1 b/scripts/aot-test.ps1 index b953c8db47..2deb23c062 100644 --- a/scripts/aot-test.ps1 +++ b/scripts/aot-test.ps1 @@ -44,6 +44,6 @@ Write-Host "::endgroup::" if ($IsLinux -and (Get-Command docker -ErrorAction SilentlyContinue)) { Write-Host "::group::Test PublishContainer" dotnet publish -p:EnableSdkContainerSupport=true -t:PublishContainer -v:detailed - docker run hello-sentry + docker run --rm hello-sentry Write-Host "::endgroup::" } From a6489ddcc29d1a537ae9e312516808acbc1fe741 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Fri, 20 Jun 2025 13:28:18 +0200 Subject: [PATCH 18/23] allow scripts for mac --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 70cf4abfe4..eb7b1b512f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -204,6 +204,7 @@ jobs: # integration tests, e.g. Directory.Build.props, nuget.config, ... sparse-checkout: | integration-test + scripts .github - name: Fetch NuGet Packages From 1086327dde9f87a299dada019519e5309ccb7a14 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Fri, 20 Jun 2025 13:34:32 +0200 Subject: [PATCH 19/23] try turning it into a pester integration test --- .github/workflows/build.yml | 4 --- integration-test/aot.Tests.ps1 | 65 ++++++++++++++++++++++++++++++++++ scripts/aot-test.ps1 | 49 ------------------------- 3 files changed, 65 insertions(+), 53 deletions(-) create mode 100644 integration-test/aot.Tests.ps1 delete mode 100644 scripts/aot-test.ps1 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index eb7b1b512f..31356e28de 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -204,7 +204,6 @@ jobs: # integration tests, e.g. Directory.Build.props, nuget.config, ... sparse-checkout: | integration-test - scripts .github - name: Fetch NuGet Packages @@ -219,9 +218,6 @@ jobs: with: path: integration-test - - name: AOT test - shell: pwsh - run: scripts/aot-test.ps1 trim-analysis: needs: build-sentry-native diff --git a/integration-test/aot.Tests.ps1 b/integration-test/aot.Tests.ps1 new file mode 100644 index 0000000000..f3ce8c1bc4 --- /dev/null +++ b/integration-test/aot.Tests.ps1 @@ -0,0 +1,65 @@ +# This file contains test cases for https://pester.dev/ +Set-StrictMode -Version Latest +$ErrorActionPreference = 'Stop' + +Describe 'Publish' { + BeforeAll { + $package = Get-ChildItem -Path "$PSScriptRoot/../src/Sentry/bin/Release/Sentry.*.nupkg" -File | Select-Object -First 1 + if (-not $package) + { + throw "No NuGet package found in src/Sentry/bin/Release." + } + + $tempDir = Join-Path ([System.IO.Path]::GetTempPath()) ([System.IO.Path]::GetRandomFileName()) + New-Item -ItemType Directory -Path $tempDir -Force | Out-Null + Set-Location $tempDir + Write-Host "Testing $package in $tempDir" + + Write-Host "::group::Setup local NuGet source" + $localPackages = Join-Path $tempDir "packages" + New-Item -ItemType Directory -Path $localPackages -Force | Out-Null + Copy-Item $package $localPackages + $localConfig = Join-Path $tempDir "nuget.conf" + Copy-Item $PSScriptRoot/nuget.config $localConfig + dotnet nuget list source --configfile $localConfig | Write-Host + Write-Host "::endgroup::" + + Write-Host "::group::Create test project" + dotnet new console --aot --name hello-sentry --output . | Write-Host + dotnet add package Sentry --prerelease --source $localPackages | Write-Host + @" +SentrySdk.Init(options => +{ + options.Dsn = "https://foo@sentry.invalid/42"; + options.Debug = true; +}); +Console.WriteLine("Hello, Sentry!"); +"@ | Set-Content Program.cs + Write-Host "::endgroup::" + } + + AfterAll { + if ($tempDir -and (Test-Path $tempDir)) + { + Remove-Item $tempDir -Recurse -Force -ErrorAction SilentlyContinue + } + } + + It 'Aot' { + dotnet publish -c Release | Write-Host + $LASTEXITCODE | Should -Be 0 + + $tfm = (Get-ChildItem -Path "bin/Release" -Directory | Select-Object -First 1).Name + $rid = (Get-ChildItem -Path "bin/Release/$tfm" -Directory | Select-Object -First 1).Name + & "bin/Release/$tfm/$rid/publish/hello-sentry" | Write-Host + $LASTEXITCODE | Should -Be 0 + } + + It 'Container' -Skip:(!$IsLinux -or !(Get-Command docker -ErrorAction SilentlyContinue)) { + dotnet publish -p:EnableSdkContainerSupport=true -t:PublishContainer | Write-Host + $LASTEXITCODE | Should -Be 0 + + docker run --rm hello-sentry | Write-Host + $LASTEXITCODE | Should -Be 0 + } +} diff --git a/scripts/aot-test.ps1 b/scripts/aot-test.ps1 deleted file mode 100644 index 2deb23c062..0000000000 --- a/scripts/aot-test.ps1 +++ /dev/null @@ -1,49 +0,0 @@ -$package = Get-ChildItem -Path "$PSScriptRoot/../src/Sentry/bin/Release/Sentry.*.nupkg" -File | Select-Object -First 1 -if (-not $package) { - Write-Error "No NuGet package found in src/Sentry/bin/Release." - exit 1 -} - -$tempDir = Join-Path ([System.IO.Path]::GetTempPath()) ([System.IO.Path]::GetRandomFileName()) -New-Item -ItemType Directory -Path $tempDir -Force | Out-Null -Set-Location $tempDir -Write-Host "Testing $package in $tempDir" -Write-Host "::group::.NET info" -dotnet --info -Write-Host "::endgroup::" - -Write-Host "::group::Setup local NuGet source" -$localPackages = Join-Path $tempDir "packages" -New-Item -ItemType Directory -Path $localPackages -Force | Out-Null -Copy-Item $package $localPackages -$localConfig = Join-Path $tempDir "nuget.conf" -Copy-Item $PSScriptRoot/../integration-test/nuget.config $localConfig -dotnet nuget list source --configfile $localConfig -Write-Host "::endgroup::" - -Write-Host "::group::Create test project" -dotnet new console --aot --name hello-sentry --output . -dotnet add package Sentry --prerelease --source $localPackages -@" -SentrySdk.Init(options => -{ - options.Dsn = "https://foo@sentry.invalid/42"; - options.Debug = true; -}); -Console.WriteLine("Hello, Sentry!"); -"@ | Set-Content Program.cs -Write-Host "::endgroup::" - -Write-Host "::group::Test PublishAot" -dotnet publish -c Release -v:detailed -$tfm = (Get-ChildItem -Path "bin/Release" -Directory | Select-Object -First 1).Name -$rid = (Get-ChildItem -Path "bin/Release/$tfm" -Directory | Select-Object -First 1).Name -& "bin/Release/$tfm/$rid/publish/hello-sentry" -Write-Host "::endgroup::" - -if ($IsLinux -and (Get-Command docker -ErrorAction SilentlyContinue)) { - Write-Host "::group::Test PublishContainer" - dotnet publish -p:EnableSdkContainerSupport=true -t:PublishContainer -v:detailed - docker run --rm hello-sentry - Write-Host "::endgroup::" -} From 44d819abfae53c96ae3090f8b689cefdd23dace5 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Fri, 20 Jun 2025 14:23:13 +0200 Subject: [PATCH 20/23] fix nuget.config --- integration-test/aot.Tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration-test/aot.Tests.ps1 b/integration-test/aot.Tests.ps1 index f3ce8c1bc4..4c8522bab2 100644 --- a/integration-test/aot.Tests.ps1 +++ b/integration-test/aot.Tests.ps1 @@ -19,7 +19,7 @@ Describe 'Publish' { $localPackages = Join-Path $tempDir "packages" New-Item -ItemType Directory -Path $localPackages -Force | Out-Null Copy-Item $package $localPackages - $localConfig = Join-Path $tempDir "nuget.conf" + $localConfig = Join-Path $tempDir "nuget.config" Copy-Item $PSScriptRoot/nuget.config $localConfig dotnet nuget list source --configfile $localConfig | Write-Host Write-Host "::endgroup::" From 8a8315bf77e63e55280fe591047c2ef412fc1a69 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Fri, 20 Jun 2025 15:12:16 +0200 Subject: [PATCH 21/23] set NUGET_PACKAGES --- integration-test/aot.Tests.ps1 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/integration-test/aot.Tests.ps1 b/integration-test/aot.Tests.ps1 index 4c8522bab2..4aa696761e 100644 --- a/integration-test/aot.Tests.ps1 +++ b/integration-test/aot.Tests.ps1 @@ -21,7 +21,9 @@ Describe 'Publish' { Copy-Item $package $localPackages $localConfig = Join-Path $tempDir "nuget.config" Copy-Item $PSScriptRoot/nuget.config $localConfig - dotnet nuget list source --configfile $localConfig | Write-Host + $env:NUGET_PACKAGES = Join-Path $tempDir "nuget" + New-Item -ItemType Directory -Path $env:NUGET_PACKAGES -Force | Out-Null + dotnet nuget list source | Write-Host Write-Host "::endgroup::" Write-Host "::group::Create test project" From 81b051f96a6d3a27c63bcc9bf92b71e387ba1713 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Fri, 20 Jun 2025 15:40:19 +0200 Subject: [PATCH 22/23] finally, apply the copy-paste fix --- CHANGELOG.md | 6 ++++++ .../Platforms/Native/buildTransitive/Sentry.Native.targets | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f1f5f36e1..5d384d4167 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## Unreleased + +### Fixes + +- Fix linking of libsentry-native to avoid DllNotFoundException in Native AOT applications ([#4298](https://github.com/getsentry/sentry-dotnet/pull/4298)) + ## 5.11.0 ### Features diff --git a/src/Sentry/Platforms/Native/buildTransitive/Sentry.Native.targets b/src/Sentry/Platforms/Native/buildTransitive/Sentry.Native.targets index 8dd9ec60ae..55e8032638 100644 --- a/src/Sentry/Platforms/Native/buildTransitive/Sentry.Native.targets +++ b/src/Sentry/Platforms/Native/buildTransitive/Sentry.Native.targets @@ -18,6 +18,13 @@ Trim="true" /> + + + <_SentryTargetFrameworkVersion>$([MSBuild]::GetTargetFrameworkVersion($(TargetFramework))) + <_SentryIsNet8OrGreater>$([MSBuild]::VersionGreaterThanOrEquals($(_SentryTargetFrameworkVersion), 8.0)) + <_SentryIsNet9OrGreater>$([MSBuild]::VersionGreaterThanOrEquals($(_SentryTargetFrameworkVersion), 9.0)) + + true From be9d67e8fbcbd1526839ef7554a998d925ad78b2 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Fri, 20 Jun 2025 22:23:33 +0200 Subject: [PATCH 23/23] fix /var vs. /private/var mismatch on macos --- integration-test/aot.Tests.ps1 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/integration-test/aot.Tests.ps1 b/integration-test/aot.Tests.ps1 index 4aa696761e..24dbc8e800 100644 --- a/integration-test/aot.Tests.ps1 +++ b/integration-test/aot.Tests.ps1 @@ -10,7 +10,8 @@ Describe 'Publish' { throw "No NuGet package found in src/Sentry/bin/Release." } - $tempDir = Join-Path ([System.IO.Path]::GetTempPath()) ([System.IO.Path]::GetRandomFileName()) + $tempDir = Resolve-Path ([System.IO.Path]::GetTempPath()) + $tempDir = Join-Path $tempDir ([System.IO.Path]::GetRandomFileName()) New-Item -ItemType Directory -Path $tempDir -Force | Out-Null Set-Location $tempDir Write-Host "Testing $package in $tempDir" @@ -21,6 +22,7 @@ Describe 'Publish' { Copy-Item $package $localPackages $localConfig = Join-Path $tempDir "nuget.config" Copy-Item $PSScriptRoot/nuget.config $localConfig + (Get-Content $localConfig) -replace '\./packages', $localPackages | Set-Content $localConfig $env:NUGET_PACKAGES = Join-Path $tempDir "nuget" New-Item -ItemType Directory -Path $env:NUGET_PACKAGES -Force | Out-Null dotnet nuget list source | Write-Host