Skip to content

Commit

Permalink
fix: upload proguard mapping (#2574)
Browse files Browse the repository at this point in the history
  • Loading branch information
bruno-garcia authored Aug 22, 2023
1 parent f7edf0e commit 87d2c11
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

- Graphql client ([#2538](https://github.com/getsentry/sentry-dotnet/pull/2538))

### Fixes

- Android: Fix proguard/r8 mapping file upload ([#2574](https://github.com/getsentry/sentry-dotnet/pull/2574))

### Dependencies

- Bump Cocoa SDK from v8.9.5 to v8.10.0 ([#2546](https://github.com/getsentry/sentry-dotnet/pull/2546), [#2550](https://github.com/getsentry/sentry-dotnet/pull/2550))
Expand Down
8 changes: 8 additions & 0 deletions samples/Sentry.Samples.Android/Sentry.Samples.Android.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
<ApplicationId>io.sentry.dotnet.samples.android</ApplicationId>
<ApplicationVersion>1</ApplicationVersion>
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
<!-- XA0119: Using fast deployment and a code shrinker at the same time is not recommended. Use fast deployment for Debug configurations and a code shrinker for Release configurations.-->
<NoWarn>$(NoWarn);XA0119</NoWarn>
</PropertyGroup>

<ItemGroup>
Expand All @@ -27,7 +29,13 @@
<PropertyGroup>
<SentryUploadSources>true</SentryUploadSources>
<SentryUploadSymbols>true</SentryUploadSymbols>
<!-- Use ProGuard (R8), and upload mapping to Sentry-->
<AndroidLinkTool Condition=" '$(AndroidLinkTool)' == '' ">r8</AndroidLinkTool>
<AndroidDexTool Condition=" '$(AndroidDexTool)' == '' ">d8</AndroidDexTool>
<SentryUploadAndroidProguardMapping>true</SentryUploadAndroidProguardMapping>
<!-- Since we're doing this in Debug builds: https://github.com/xamarin/xamarin-android/issues/6612#issuecomment-1006125892-->
<PublishTrimmed>true</PublishTrimmed>
<AndroidLinkMode>full</AndroidLinkMode>
</PropertyGroup>

</Project>
19 changes: 12 additions & 7 deletions src/Sentry/buildTransitive/Sentry.targets
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<SentryUploadSources Condition="'$(SentryUploadSources)' == ''">false</SentryUploadSources>

<!-- This property controls if the Sentry CLI is to be used at all. Setting false will disable all Sentry CLI usage. -->
<UseSentryCLI Condition="'$(UseSentryCLI)' == '' And ('$(SentryUploadSymbols)' == 'true' Or '$(SentryUploadSources)' == 'true')">true</UseSentryCLI>
<UseSentryCLI Condition="'$(UseSentryCLI)' == '' And ('$(SentryUploadSymbols)' == 'true' Or '$(SentryUploadSources)' == 'true' Or $(SentryUploadAndroidProguardMapping) == 'true')">true</UseSentryCLI>
</PropertyGroup>
</Target>

Expand Down Expand Up @@ -85,8 +85,10 @@

<SentryCLIUploadOptions Condition="'$(SentryOrg)' != ''">$(SentryCLIUploadOptions) --org $(SentryOrg)</SentryCLIUploadOptions>
<SentryCLIUploadOptions Condition="'$(SentryProject)' != ''">$(SentryCLIUploadOptions) --project $(SentryProject)</SentryCLIUploadOptions>
<SentryCLIUploadCommand>$(SentryCLIBaseCommand) debug-files upload</SentryCLIUploadCommand>
<SentryCLIUploadCommand Condition="'$(SentryCLIUploadOptions.Trim())' != ''">$(SentryCLIUploadCommand) $(SentryCLIUploadOptions.Trim())</SentryCLIUploadCommand>
<SentryCLIDebugFilesUploadCommand>$(SentryCLIBaseCommand) debug-files upload</SentryCLIDebugFilesUploadCommand>
<SentryCLIDebugFilesUploadCommand Condition="'$(SentryCLIUploadOptions.Trim())' != ''">$(SentryCLIDebugFilesUploadCommand) $(SentryCLIUploadOptions.Trim())</SentryCLIDebugFilesUploadCommand>
<SentryCLIProGuardMappingUploadCommand>$(SentryCLIBaseCommand) upload-proguard</SentryCLIProGuardMappingUploadCommand>
<SentryCLIProGuardMappingUploadCommand Condition="'$(SentryCLIUploadOptions.Trim())' != ''">$(SentryCLIProGuardMappingUploadCommand) $(SentryCLIUploadOptions.Trim())</SentryCLIProGuardMappingUploadCommand>
</PropertyGroup>

<PropertyGroup Condition="'$(SentryCLI)' != ''">
Expand Down Expand Up @@ -132,7 +134,7 @@
<SentryCLIUploadSymbolType Include="dsym" Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'" />
</ItemGroup>

<Exec Command="$(SentryCLIUploadCommand) @(SentryCLIUploadSymbolType -> '-t %(Identity)', ' ') $(OutputPath)" IgnoreExitCode="true" ContinueOnError="WarnAndContinue">
<Exec Command="$(SentryCLIDebugFilesUploadCommand) @(SentryCLIUploadSymbolType -> '-t %(Identity)', ' ') $(OutputPath)" IgnoreExitCode="true" ContinueOnError="WarnAndContinue">
<Output TaskParameter="ExitCode" PropertyName="_SentryCLIExitCode" />
</Exec>

Expand All @@ -154,7 +156,7 @@
</PropertyGroup>

<Exec Command="&quot;$(SentryCLI)&quot; debug-files bundle-sources $(_SentryDebugInfoFile)" IgnoreExitCode="true" ContinueOnError="WarnAndContinue" />
<Exec Command="$(SentryCLIUploadCommand) $(_SentrySourceBundle)" IgnoreExitCode="true" ContinueOnError="WarnAndContinue" Condition="Exists('$(_SentrySourceBundle)')">
<Exec Command="$(SentryCLIDebugFilesUploadCommand) $(_SentrySourceBundle)" IgnoreExitCode="true" ContinueOnError="WarnAndContinue" Condition="Exists('$(_SentrySourceBundle)')">
<Output TaskParameter="ExitCode" PropertyName="_SentryCLIExitCode" />
</Exec>

Expand All @@ -163,12 +165,15 @@
</Target>

<!-- Upload Android Proguard mapping file to Sentry after the build. -->
<Target Name="UploadAndroidProguardMappingFileToSentry" AfterTargets="Build;UploadSymbolsToSentry"
<Target Name="UploadAndroidProguardMappingFileToSentry" AfterTargets="Build"
Condition="'$(SentryUploadAndroidProguardMapping)' == 'true' And '$(AndroidProguardMappingFile)' != ''">

<Message Importance="High" Text="Preparing to upload Android Proguard mapping to Sentry for '$(MSBuildProjectName)': $(AndroidProguardMappingFile))" />

<Exec Command="&quot;$(SentryCLI)&quot; upload-proguard $(AndroidProguardMappingFile)" IgnoreExitCode="true" ContinueOnError="WarnAndContinue" />
<Exec Command="$(SentryCLIProGuardMappingUploadCommand) $(AndroidProguardMappingFile)" IgnoreExitCode="true" ContinueOnError="WarnAndContinue">
<Output TaskParameter="ExitCode" PropertyName="_SentryCLIExitCode" />
</Exec>
<Warning Condition="'$(_SentryCLIExitCode)' != '0'" Text="Sentry CLI could not upload proguard mapping." />

</Target>
</Project>

0 comments on commit 87d2c11

Please sign in to comment.