Skip to content

Commit 73f5dea

Browse files
Alternate solution to inject the ContainerBaseImage
1 parent d61e87d commit 73f5dea

File tree

2 files changed

+21
-24
lines changed

2 files changed

+21
-24
lines changed

.github/workflows/build.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,13 +264,23 @@ jobs:
264264
path: src
265265

266266
- name: Integration test
267+
if: ${{ (matrix.rid != 'linux-musl-x64') && (matrix.rid != 'linux-musl-arm64') }}
268+
uses: getsentry/github-workflows/sentry-cli/integration-test/@v2
269+
with:
270+
path: integration-test
271+
272+
# For the linux-musl runtimes we have to pin the ContainerBaseImage for preview or RC builds, since
273+
# these don't conform to the normal naming conventions and don't get resolved automatically. We do
274+
# by passing it as parameter to aot.Tests.ps1 via an environment variable
275+
- name: Integration test (musl)
276+
if: ${{ (matrix.rid == 'linux-musl-x64') || (matrix.rid == 'linux-musl-arm64') }}
267277
uses: getsentry/github-workflows/sentry-cli/integration-test/@v2
268278
env:
269-
RuntimeIdentifier: ${{ matrix.rid }}
279+
ContainerBaseImage: 'mcr.microsoft.com/dotnet/nightly/runtime-deps:10.0-preview-alpine3.22'
270280
with:
271281
path: integration-test
272282

273-
msbuild:
283+
ms-build:
274284
needs: build-sentry-native
275285
name: MSBuild
276286
runs-on: windows-latest

integration-test/aot.Tests.ps1

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,6 @@ Describe 'Publish' {
3131
Write-Host "::group::Create test project"
3232
dotnet new console --aot --name hello-sentry --output . | Write-Host
3333
dotnet add package Sentry --prerelease --source $localPackages | Write-Host
34-
35-
# Pin the ContainerBaseImage on linux-musl... otherwise the .NET 10 preview7 can't find it
36-
$projPath = Join-Path (Get-Location) 'hello-sentry.csproj'
37-
[xml]$proj = Get-Content $projPath
38-
$pg = $proj.CreateElement('PropertyGroup')
39-
$pg.SetAttribute('Condition', '$([System.String]::new(''$(RuntimeIdentifier)'').StartsWith(''linux-musl''))')
40-
$cbi = $proj.CreateElement('ContainerBaseImage')
41-
$cbi.InnerText = 'mcr.microsoft.com/dotnet/nightly/runtime-deps:10.0-preview-alpine3.22'
42-
$pg.AppendChild($cbi) | Out-Null
43-
$proj.Project.AppendChild($pg) | Out-Null
44-
$proj.Save($projPath)
45-
46-
# Minimal Program.cs
4734
@"
4835
SentrySdk.Init(options =>
4936
{
@@ -64,21 +51,21 @@ Console.WriteLine("Hello, Sentry!");
6451

6552
It 'Aot' {
6653
$rid = $env:RuntimeIdentifier
67-
if ($rid)
68-
{
54+
$baseImage = $env:ContainerBaseImage
55+
$publishArgs = @('-c', 'Release')
56+
if ($rid) {
6957
Write-Host "Environment RuntimeIdentifier: $rid"
70-
dotnet publish -c Release -r $rid | Write-Host
58+
$publishArgs += @('-r', $rid)
7159
}
72-
else
73-
{
74-
Write-Host "Implicit RuntimeIdentifier"
75-
dotnet publish -c Release | Write-Host
60+
if ($baseImage) {
61+
Write-Host "Using ContainerBaseImage: $baseImage"
62+
$publishArgs += "-p:ContainerBaseImage=$baseImage"
7663
}
64+
dotnet publish @publishArgs | Write-Host
7765
$LASTEXITCODE | Should -Be 0
7866

7967
$tfm = (Get-ChildItem -Path "bin/Release" -Directory | Select-Object -First 1).Name
80-
if (-not $rid)
81-
{
68+
if (-not $rid) {
8269
$rid = (Get-ChildItem -Path "bin/Release/$tfm" -Directory | Select-Object -First 1).Name
8370
}
8471
& "bin/Release/$tfm/$rid/publish/hello-sentry" | Write-Host

0 commit comments

Comments
 (0)