Skip to content

Commit

Permalink
fix: upload Android native symbols (#2876)
Browse files Browse the repository at this point in the history
  • Loading branch information
vaind authored Nov 21, 2023
1 parent 89b2f6a commit c32be36
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 5 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@

## Unreleased - 4.x

### API breaking Changes

- ISpanTracer has been renamed back again to ISpan, to make it easier to upgrade from v3.x to v4.x ([#2870](https://github.com/getsentry/sentry-dotnet/pull/2870))

### Fixes

- Android native symbol upload ([#2876](https://github.com/getsentry/sentry-dotnet/pull/2876))

## 4.0.0-beta.1

### Features
Expand Down
8 changes: 7 additions & 1 deletion integration-test/cli.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,13 @@ Describe 'MAUI' -ForEach @(

It "uploads symbols and sources for an Android build" {
$result = RunDotnetWithSentryCLI 'build' 'maui-app' $True $True "$framework-android"
$result.UploadedDebugFiles() | Sort-Object -Unique | Should -Be @('maui-app.pdb')
$result.UploadedDebugFiles() | Sort-Object -Unique | Should -Be @(
'libsentry-android.so',
'libsentry.so',
'libsentrysupplemental.so',
'libxamarin-app.so',
'maui-app.pdb'
)
$result.ScriptOutput | Should -AnyElementMatch 'Found 1 debug information file \(1 with embedded sources\)'
}

Expand Down
23 changes: 19 additions & 4 deletions src/Sentry/buildTransitive/Sentry.targets
Original file line number Diff line number Diff line change
Expand Up @@ -158,29 +158,44 @@
<SentryCLIUploadSymbolType Include="portablepdb" />
<SentryCLIUploadSymbolType Include="dsym" Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'" />
<SentryCLIUploadSymbolType Include="dsym" Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'" />
<SentryCLIUploadSymbolType Include="elf" Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'" />
</ItemGroup>

<!-- Upload symbols to Sentry after the build. -->
<Target Name="UploadDebugInfoToSentry" AfterTargets="$(SentryCLIUploadAfterTargets)" DependsOnTargets="PrepareSentryCLI"
Condition="'$(SentryCLI)' != '' and ('$(SentryUploadSymbols)' == 'true' or '$(SentryUploadSources)' == 'true')">

<!-- For Android, we need to upload native symbols, but there's no point in uploading the intermediary ".dll.so" which just ended up being combined into the final app. -->
<ItemGroup Condition="'$(IntermediateOutputPath)' != '' and $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">
<AndroidNativeSymbolFiles Include="$(IntermediateOutputPath)**/*.so" />
</ItemGroup>
<ItemGroup>
<AndroidNativeSymbolFilesExceptDll Include="@(AndroidNativeSymbolFiles)"
Condition="!$([System.Text.RegularExpressions.Regex]::Match(%(Identity),'.*.dll.so').Success)"/>
</ItemGroup>

<PropertyGroup>
<SentryCLIUploadItems>$(SentryCLIUploadDirectory)</SentryCLIUploadItems>
<SentryCLIUploadItems Condition="'@(AndroidNativeSymbolFilesExceptDll)' != ''">$(SentryCLIUploadItems) @(AndroidNativeSymbolFilesExceptDll -> '%(Identity)', ' ')</SentryCLIUploadItems>
</PropertyGroup>

<!-- if (UploadSymbols && UploadSources) { -->
<Message Importance="High"
Condition="'$(SentryUploadSymbols)' == 'true' and '$(SentryUploadSources)' == 'true'"
Text="Preparing upload to Sentry for project '$(MSBuildProjectName)' ($(Configuration)/$(TargetFramework)): collecting debug symbols and referenced source code from $(SentryCLIUploadDirectory)" />
Text="Preparing upload to Sentry for project '$(MSBuildProjectName)' ($(Configuration)/$(TargetFramework)): collecting debug symbols and referenced source code from $(SentryCLIUploadItems)" />
<Exec
Condition="'$(SentryUploadSymbols)' == 'true' and '$(SentryUploadSources)' == 'true'"
Command="$(SentryCLIDebugFilesUploadCommand) @(SentryCLIUploadSymbolType -> '-t %(Identity)', ' ') --include-sources $(SentryCLIUploadDirectory)"
Command="$(SentryCLIDebugFilesUploadCommand) @(SentryCLIUploadSymbolType -> '-t %(Identity)', ' ') --include-sources $(SentryCLIUploadItems)"
IgnoreExitCode="true" ContinueOnError="WarnAndContinue">
<Output TaskParameter="ExitCode" PropertyName="_SentryCLIExitCode" />
</Exec>
<!-- } else if (UploadSymbols && !UploadSources) { -->
<Message Importance="High"
Condition="'$(SentryUploadSymbols)' == 'true' and '$(SentryUploadSources)' != 'true'"
Text="Preparing upload to Sentry for project '$(MSBuildProjectName)' ($(Configuration)/$(TargetFramework)): collecting debug symbols from $(SentryCLIUploadDirectory)" />
Text="Preparing upload to Sentry for project '$(MSBuildProjectName)' ($(Configuration)/$(TargetFramework)): collecting debug symbols from $(SentryCLIUploadItems)" />
<Exec
Condition="'$(SentryUploadSymbols)' == 'true' and '$(SentryUploadSources)' != 'true'"
Command="$(SentryCLIDebugFilesUploadCommand) @(SentryCLIUploadSymbolType -> '-t %(Identity)', ' ') $(SentryCLIUploadDirectory)"
Command="$(SentryCLIDebugFilesUploadCommand) @(SentryCLIUploadSymbolType -> '-t %(Identity)', ' ') $(SentryCLIUploadItems)"
IgnoreExitCode="true" ContinueOnError="WarnAndContinue">
<Output TaskParameter="ExitCode" PropertyName="_SentryCLIExitCode" />
</Exec>
Expand Down

0 comments on commit c32be36

Please sign in to comment.