Skip to content

Commit 4581417

Browse files
authored
fix: Generate and inject uuid to apk and upload proguard with that uuid (#4532)
Automatically generate a UUID to associate an APK and its ProGuard mapping file that will be uploaded to Sentry. Fixes #3872
1 parent 58b5da0 commit 4581417

File tree

3 files changed

+30
-7
lines changed

3 files changed

+30
-7
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ jobs:
267267
path: src
268268

269269
- name: Integration test
270-
uses: getsentry/github-workflows/sentry-cli/integration-test/@v2
270+
uses: getsentry/github-workflows/sentry-cli/integration-test/@a5e409bd5bad4c295201cdcfe862b17c50b29ab7 # v2.14.1
271271
with:
272272
path: integration-test
273273

@@ -348,7 +348,7 @@ jobs:
348348
path: src
349349

350350
- name: Test AOT
351-
uses: getsentry/github-workflows/sentry-cli/integration-test/@v2
351+
uses: getsentry/github-workflows/sentry-cli/integration-test/@a5e409bd5bad4c295201cdcfe862b17c50b29ab7 # v2.14.1
352352
env:
353353
RuntimeIdentifier: ${{ matrix.rid }}
354354
with:

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## Unreleased
4+
5+
### Fixes
6+
7+
- In MAUI Android apps, generate and inject UUID to APK and upload ProGuard mapping to Sentry with the UUID ([#4532](https://github.com/getsentry/sentry-dotnet/pull/4532))
8+
39
## 5.15.1
410

511
### Fixes

src/Sentry/buildTransitive/Sentry.targets

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
<PropertyGroup>
2020
<SentryAttributesFile>Sentry.Attributes$(MSBuildProjectExtension.Replace('proj', ''))</SentryAttributesFile>
21+
<SentryProGuardUUID Condition="'$(SentryProGuardUUID)' == ''">$([System.Guid]::NewGuid())</SentryProGuardUUID>
2122
</PropertyGroup>
2223

2324
<Target Name="_SentryEnsureAndroidEnableAssemblyCompressionDisabled"
@@ -68,7 +69,7 @@
6869
We're explicitly skipping uploads for Sentry projects because they interfere with CLI integration test asserts. -->
6970
<UseSentryCLI Condition="
7071
'$(UseSentryCLI)' == ''
71-
and ('$(SentryUploadSymbols)' == 'true' or '$(SentryUploadSources)' == 'true' or $(SentryUploadAndroidProguardMapping) == 'true' or $(SentryCreateRelease) == 'true' or $(SentrySetCommits) == 'true')
72+
and ('$(SentryUploadSymbols)' == 'true' or '$(SentryUploadSources)' == 'true' or $(SentryUploadAndroidProGuardMapping) == 'true' or $(SentryCreateRelease) == 'true' or $(SentrySetCommits) == 'true')
7273
and '$(MSBuildProjectName)' != 'Sentry'
7374
and !$(MSBuildProjectName.StartsWith('Sentry.'))">true</UseSentryCLI>
7475
</PropertyGroup>
@@ -125,11 +126,14 @@
125126
<SentrySetCommitReleaseOptions Condition="'$(SentryOrg)' != ''">$(SentrySetCommitReleaseOptions) --org $(SentryOrg)</SentrySetCommitReleaseOptions>
126127
<SentrySetCommitReleaseOptions Condition="'$(SentryProject)' != ''">$(SentrySetCommitReleaseOptions) --project $(SentryProject)</SentrySetCommitReleaseOptions>
127128

129+
<_SentryCLIProGuardOptions Condition="'$(SentryProGuardUUID)' != ''">$(_SentryCLIProGuardOptions) --uuid &quot;$(SentryProGuardUUID)&quot;</_SentryCLIProGuardOptions>
130+
<_SentryCLIProGuardOptions Condition="'$(_SentryCLIProGuardOptions.Trim())' != ''">$(_SentryCLIProGuardOptions.Trim())</_SentryCLIProGuardOptions>
131+
128132
<SentryCLIUploadOptions Condition="'$(SentryOrg)' != ''">$(SentryCLIUploadOptions) --org $(SentryOrg)</SentryCLIUploadOptions>
129133
<SentryCLIUploadOptions Condition="'$(SentryProject)' != ''">$(SentryCLIUploadOptions) --project $(SentryProject)</SentryCLIUploadOptions>
130134
<SentryCLIDebugFilesUploadCommand>$(SentryCLIBaseCommand) debug-files upload</SentryCLIDebugFilesUploadCommand>
131135
<SentryCLIDebugFilesUploadCommand Condition="'$(SentryCLIUploadOptions.Trim())' != ''">$(SentryCLIDebugFilesUploadCommand) $(SentryCLIUploadOptions.Trim())</SentryCLIDebugFilesUploadCommand>
132-
<SentryCLIProGuardMappingUploadCommand>$(SentryCLIBaseCommand) upload-proguard</SentryCLIProGuardMappingUploadCommand>
136+
<SentryCLIProGuardMappingUploadCommand>$(SentryCLIBaseCommand) upload-proguard $(_SentryCLIProGuardOptions)</SentryCLIProGuardMappingUploadCommand>
133137
<SentryCLIProGuardMappingUploadCommand Condition="'$(SentryCLIUploadOptions.Trim())' != ''">$(SentryCLIProGuardMappingUploadCommand) $(SentryCLIUploadOptions.Trim())</SentryCLIProGuardMappingUploadCommand>
134138
</PropertyGroup>
135139

@@ -267,9 +271,22 @@
267271
<Warning Condition="'$(_SentryCLIExitCode)' != '0'" Text="Sentry CLI could not upload debug files." />
268272
</Target>
269273

270-
<!-- Upload Android Proguard mapping file to Sentry after the build. -->
271-
<Target Name="UploadAndroidProguardMappingFileToSentry" AfterTargets="Build" DependsOnTargets="PrepareSentryCLI"
272-
Condition="'$(SentryCLI)' != '' and '$(SentryUploadAndroidProguardMapping)' == 'true' And '$(AndroidProguardMappingFile)' != ''">
274+
<Target Name="UpdateAndroidMetadata" BeforeTargets="GetAssemblyAttributes"
275+
Condition="
276+
$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'
277+
and '$(SentryUploadAndroidProGuardMapping)' == 'true'">
278+
279+
<ItemGroup>
280+
<AssemblyAttribute Include="Android.App.MetaData">
281+
<_Parameter1>io.sentry.proguard-uuid</_Parameter1>
282+
<Value>$(SentryProGuardUUID)</Value>
283+
</AssemblyAttribute>
284+
</ItemGroup>
285+
</Target>
286+
287+
<!-- Upload Android ProGuard mapping file to Sentry after the build. -->
288+
<Target Name="UploadAndroidProGuardMappingFileToSentry" AfterTargets="Build" DependsOnTargets="PrepareSentryCLI"
289+
Condition="'$(SentryCLI)' != '' and '$(SentryUploadAndroidProGuardMapping)' == 'true' And '$(AndroidProguardMappingFile)' != ''">
273290

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

0 commit comments

Comments
 (0)