Skip to content

WIP: WinUI & Native #4297

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 72 additions & 19 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/device-tests-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ on:

jobs:
build:
if: false
name: Build (${{ matrix.tfm }})
runs-on: ubuntu-latest
strategy:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/device-tests-ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ on:

jobs:
ios-tests:
if: false
runs-on: macos-15
env:
DOTNET_CLI_TELEMETRY_OPTOUT: 1
Expand Down
3 changes: 2 additions & 1 deletion Sentry-CI-Build-Windows-arm64.slnf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
}
}
3 changes: 2 additions & 1 deletion Sentry-CI-Build-Windows.slnf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
}
}
2 changes: 2 additions & 0 deletions Sentry.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
29 changes: 22 additions & 7 deletions scripts/build-sentry-native.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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 = @()
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
3 changes: 3 additions & 0 deletions scripts/generate-solution-filters-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -95,6 +96,7 @@ filterConfigs:
- "**/*AndroidTestApp.csproj"
- "**/*DeviceTests*.csproj"
- "**/*.AspNet.Tests.csproj"
- "**/*WinUITestApp.csproj"

- outputPath: Sentry-CI-Build-Windows.slnf
include:
Expand Down Expand Up @@ -255,6 +257,7 @@ filterConfigs:
- "**/*Android*.csproj"
- "**/*Ios*.csproj"
- "**/*Maui*.csproj"
- "**/*WinUI*.csproj"

- outputPath: SentryNoSamples.slnf
include:
Expand Down
1 change: 1 addition & 0 deletions src/Sentry/Platforms/Native/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
sentry-native
runtimes
37 changes: 30 additions & 7 deletions src/Sentry/Platforms/Native/Sentry.Native.targets
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<SentryNativeBuildScript>../../scripts/build-sentry-native.ps1</SentryNativeBuildScript>
<SentryNativeBuildInputs>../../.git/modules/modules/sentry-native/HEAD;$(MSBuildThisFileDirectory)Sentry.Native.targets;$(SentryNativeBuildScript)</SentryNativeBuildInputs>
<SentryNativeOutputDirectory>$(MSBuildThisFileDirectory)sentry-native\</SentryNativeOutputDirectory>
<SentryNativeRuntimeDirectory>$(MSBuildThisFileDirectory)runtimes\</SentryNativeRuntimeDirectory>
<!-- List of runtime identifiers: https://github.com/dotnet/runtime/blob/main/src/libraries/Microsoft.NETCore.Platforms/src/runtime.json -->
<NativeLibRelativePath-win-x64>win-x64</NativeLibRelativePath-win-x64>
<SentryNativeOutputDirectory-win-x64>$(SentryNativeOutputDirectory)$(NativeLibRelativePath-win-x64)\</SentryNativeOutputDirectory-win-x64>
Expand All @@ -19,8 +20,14 @@
<SentryNativeOutputDirectory-linux-arm64>$(SentryNativeOutputDirectory)$(NativeLibRelativePath-linux-arm64)\</SentryNativeOutputDirectory-linux-arm64>
<NativeLibRelativePath-osx>osx</NativeLibRelativePath-osx>
<SentryNativeOutputDirectory-osx>$(SentryNativeOutputDirectory)$(NativeLibRelativePath-osx)\</SentryNativeOutputDirectory-osx>
<SentryNativeBuildOutputs Condition="'$(RuntimeIdentifier)' == 'win-x64'">$(SentryNativeOutputDirectory-win-x64)lib$(SentryNativeLibraryName).lib</SentryNativeBuildOutputs>
<SentryNativeBuildOutputs Condition="'$(RuntimeIdentifier)' == 'win-arm64'">$(SentryNativeOutputDirectory-win-arm64)lib$(SentryNativeLibraryName).lib</SentryNativeBuildOutputs>
<SentryNativeBuildOutputs Condition="'$(RuntimeIdentifier)' == 'win-x64'">
$(SentryNativeOutputDirectory-win-x64)lib$(SentryNativeLibraryName).lib
$(SentryNativeRuntimeDirectory)win-x64\native\lib$(SentryNativeLibraryName).dll
</SentryNativeBuildOutputs>
<SentryNativeBuildOutputs Condition="'$(RuntimeIdentifier)' == 'win-arm64'">
$(SentryNativeOutputDirectory-win-arm64)lib$(SentryNativeLibraryName).lib
$(SentryNativeRuntimeDirectory)win-arm64\native\lib$(SentryNativeLibraryName).dll
</SentryNativeBuildOutputs>
<SentryNativeBuildOutputs Condition="'$(RuntimeIdentifier)' == 'linux-x64'">$(SentryNativeOutputDirectory-linux-x64)lib$(SentryNativeLibraryName).a</SentryNativeBuildOutputs>
<SentryNativeBuildOutputs Condition="'$(RuntimeIdentifier)' == 'linux-musl-x64'">$(SentryNativeOutputDirectory-linux-musl-x64)lib$(SentryNativeLibraryName).a</SentryNativeBuildOutputs>
<SentryNativeBuildOutputs Condition="'$(RuntimeIdentifier)' == 'linux-arm64'">$(SentryNativeOutputDirectory-linux-arm64)lib$(SentryNativeLibraryName).a</SentryNativeBuildOutputs>
Expand All @@ -34,35 +41,49 @@
</ItemGroup>

<!-- Packaging the native library (NOTE: $(RuntimeIdentifier) is not set) -->
<ItemGroup Condition="'$(CI_PUBLISHING_BUILD)' == 'true' or '$([System.Runtime.InteropServices.RuntimeInformation]::RuntimeIdentifier)' == 'win-x64'">
<ItemGroup Condition="'$(CI_PUBLISHING_BUILD)' == 'true' or '$(NETCoreSdkRuntimeIdentifier)' == 'win-x64'">
<None Include="$(SentryNativeOutputDirectory-win-x64)$(SentryNativeLibraryName).lib">
<Pack>true</Pack>
<PackagePath>\sentry-native\$(NativeLibRelativePath-win-x64)</PackagePath>
</None>
<None Include="$(SentryNativeRuntimeDirectory)win-x64\native\$(SentryNativeLibraryName).dll"
Condition="'$(NETCoreSdkRuntimeIdentifier)' == 'win-x64' and ('$(TargetPlatformIdentifier)' == '' or '$(TargetPlatformIdentifier)' == 'windows')">
<Pack>true</Pack>
<PackagePath>\runtimes\win-x64\native</PackagePath>
<Link>%(Filename)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

<ItemGroup Condition="'$(CI_PUBLISHING_BUILD)' == 'true' or '$([System.Runtime.InteropServices.RuntimeInformation]::RuntimeIdentifier)' == 'win-arm64'">
<ItemGroup Condition="'$(CI_PUBLISHING_BUILD)' == 'true' or '$(NETCoreSdkRuntimeIdentifier)' == 'win-arm64'">
<None Include="$(SentryNativeOutputDirectory-win-arm64)$(SentryNativeLibraryName).lib">
<Pack>true</Pack>
<PackagePath>\sentry-native\$(NativeLibRelativePath-win-arm64)</PackagePath>
</None>
<None Include="$(SentryNativeRuntimeDirectory)win-arm64\native\$(SentryNativeLibraryName).dll"
Condition="'$(NETCoreSdkRuntimeIdentifier)' == 'win-arm64' and ('$(TargetPlatformIdentifier)' == '' or '$(TargetPlatformIdentifier)' == 'windows')">
<Pack>true</Pack>
<PackagePath>\runtimes\win-arm64\native</PackagePath>
<Link>%(Filename)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

<ItemGroup Condition="'$(CI_PUBLISHING_BUILD)' == 'true' or '$([System.Runtime.InteropServices.RuntimeInformation]::RuntimeIdentifier)' == 'linux-x64'">
<ItemGroup Condition="'$(CI_PUBLISHING_BUILD)' == 'true' or '$(NETCoreSdkRuntimeIdentifier)' == 'linux-x64'">
<None Include="$(SentryNativeOutputDirectory-linux-x64)lib$(SentryNativeLibraryName).a">
<Pack>true</Pack>
<PackagePath>\sentry-native\$(NativeLibRelativePath-linux-x64)</PackagePath>
</None>
</ItemGroup>

<ItemGroup Condition="'$(CI_PUBLISHING_BUILD)' == 'true' or '$([System.Runtime.InteropServices.RuntimeInformation]::RuntimeIdentifier)' == 'linux-musl-x64'">
<ItemGroup Condition="'$(CI_PUBLISHING_BUILD)' == 'true' or '$(NETCoreSdkRuntimeIdentifier)' == 'linux-musl-x64'">
<None Include="$(SentryNativeOutputDirectory-linux-musl-x64)lib$(SentryNativeLibraryName).a">
<Pack>true</Pack>
<PackagePath>\sentry-native\$(NativeLibRelativePath-linux-musl-x64)</PackagePath>
</None>
</ItemGroup>

<ItemGroup Condition="'$(CI_PUBLISHING_BUILD)' == 'true' or '$([System.Runtime.InteropServices.RuntimeInformation]::RuntimeIdentifier)' == 'linux-arm64'">
<ItemGroup Condition="'$(CI_PUBLISHING_BUILD)' == 'true' or '$(NETCoreSdkRuntimeIdentifier)' == 'linux-arm64'">
<None Include="$(SentryNativeOutputDirectory-linux-arm64)lib$(SentryNativeLibraryName).a">
<Pack>true</Pack>
<PackagePath>\sentry-native\$(NativeLibRelativePath-linux-arm64)</PackagePath>
Expand All @@ -79,7 +100,9 @@
<Target Name="CleanNativeSDK" BeforeTargets="CoreClean" Condition="'$(_SentryIsNet8OrGreater)' == 'true'">
<Message Text="Inside Custom Clean" Importance="high"/>
<RemoveDir Directories="$(SentryNativeOutputDirectory)" />
<RemoveDir Directories="$(SentryNativeRuntimeDirectory)" />
<RemoveDir Directories="$(SentryNativeSourceDirectory)build" />
<RemoveDir Directories="$(SentryNativeSourceDirectory)build-shared" />
</Target>

<!-- Build the Sentry Native SDK (this only runs on local machines because in CI we expect the SDK to be
Expand Down
Loading