From 4980efafc254a8436ed0945fdae5f3f9f9b4d063 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Thu, 9 Apr 2026 10:37:19 +0200 Subject: [PATCH 1/2] test(aot): build with MSBuildTreatWarningsAsErrors Projects using MSBuildTreatWarningsAsErrors=true would fail to publish with Native AOT due to warnings. Add a test to prevent such warnings slipping in. Co-Authored-By: Claude Opus 4.6 (1M context) --- integration-test/aot.Tests.ps1 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/integration-test/aot.Tests.ps1 b/integration-test/aot.Tests.ps1 index 269e8d14ae..84babcb2ba 100644 --- a/integration-test/aot.Tests.ps1 +++ b/integration-test/aot.Tests.ps1 @@ -72,6 +72,11 @@ Console.WriteLine("Hello, Sentry!"); $LASTEXITCODE | Should -Be 0 } + It 'MSBuildTreatWarningsAsErrors' -Skip:(!$IsWindows) { + dotnet publish -c Release -p:MSBuildTreatWarningsAsErrors=true | 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 From bfb5565e42ef3cecff797e6c51eb8386326fc535 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Fri, 10 Apr 2026 10:33:56 +0200 Subject: [PATCH 2/2] test(aot): fold warnings-as-errors into the main Aot test Enable both TreatWarningsAsErrors and MSBuildTreatWarningsAsErrors in the main Aot publish test (all platforms) and drop the separate Windows-only MSBuildTreatWarningsAsErrors block. Portable PDBs make the original Windows-only scoping unnecessary, and reusing the existing test avoids a second publish while also exercising the resulting binary at runtime. Co-Authored-By: Claude Opus 4.6 (1M context) --- integration-test/aot.Tests.ps1 | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/integration-test/aot.Tests.ps1 b/integration-test/aot.Tests.ps1 index 84babcb2ba..fc2e7e755c 100644 --- a/integration-test/aot.Tests.ps1 +++ b/integration-test/aot.Tests.ps1 @@ -52,8 +52,16 @@ Console.WriteLine("Hello, Sentry!"); It 'Aot' { $rid = $env:RuntimeIdentifier $baseImage = $env:ContainerBaseImage - $publishArgs = @('-c', 'Release') - if ($rid) { + # To exclude specific warnings without disabling warnings-as-errors entirely, add: + # '-p:WarningsNotAsErrors=CS####;IL####' # compiler/analyzer warnings (CS, IL2###, IL3###) + # '-p:MSBuildWarningsNotAsErrors=MSB####' # MSBuild task warnings (MSB###) + $publishArgs = @( + '-c', 'Release', + '-p:TreatWarningsAsErrors=true', + '-p:MSBuildTreatWarningsAsErrors=true' + ) + if ($rid) + { Write-Host "Environment RuntimeIdentifier: $rid" $publishArgs += @('-r', $rid) } @@ -72,11 +80,6 @@ Console.WriteLine("Hello, Sentry!"); $LASTEXITCODE | Should -Be 0 } - It 'MSBuildTreatWarningsAsErrors' -Skip:(!$IsWindows) { - dotnet publish -c Release -p:MSBuildTreatWarningsAsErrors=true | 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