Skip to content
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

Allow SentryUploadSources to work even when not uploading symbols #2197

Merged
merged 3 commits into from
Feb 24, 2023
Merged
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Features

- Allow `SentryUploadSources` to work even when not uploading symbols ([#2197](https://github.com/getsentry/sentry-dotnet/pull/2197))

### Fixes

- Fix assembly not found on Android in Debug configuration ([#2175](https://github.com/getsentry/sentry-dotnet/pull/2175))
Expand Down
43 changes: 38 additions & 5 deletions src/Sentry/buildTransitive/Sentry.targets
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@

<Target Name="CheckSentryCLI" AfterTargets="Build" Condition="'$(InnerTargets)' == ''">
<PropertyGroup>
<!-- This property controls whether symbols are to be sent to Sentry. -->
<!-- Set defaults for the Sentry properties. -->
<SentryUploadSymbols Condition="'$(SentryUploadSymbols)' == '' And '$(Configuration)' == 'Release'">true</SentryUploadSymbols>
<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')">true</UseSentryCLI>
<UseSentryCLI Condition="'$(UseSentryCLI)' == '' And ('$(SentryUploadSymbols)' == 'true' Or '$(SentryUploadSources)' == 'true')">true</UseSentryCLI>
</PropertyGroup>
</Target>

Expand Down Expand Up @@ -95,8 +96,9 @@
</PropertyGroup>
</Target>

<!-- Upload debug information files to Sentry after the build. -->
<Target Name="UploadSymbolsToSentry" AfterTargets="Build;Publish" DependsOnTargets="PrepareSentryCLI" Condition="'$(SentryUploadSymbols)' == 'true' And '$(SentryCLI)' != ''">
<!-- Upload symbols (and possibly sources) to Sentry after the build. -->
<Target Name="UploadSymbolsToSentry" AfterTargets="Build;Publish" DependsOnTargets="PrepareSentryCLI"
Condition="'$(SentryUploadSymbols)' == 'true' And '$(SentryCLI)' != ''">

<Warning Condition="'$(SentryUploadSources)' == 'true' And '$(EmbedAllSources)' == 'true'"
Text="Both SentryUploadSources and EmbedAllSources are enabled. Disabling SentryUploadSources." />
Expand All @@ -110,7 +112,7 @@
Text="Preparing to upload debug symbols and sources to Sentry for $(MSBuildProjectName) ($(Configuration)/$(TargetFramework))" />

<PropertyGroup>
<_SentryCLICommand>&quot;$(SentryCLI)&quot; upload-dif</_SentryCLICommand>
<_SentryCLICommand>&quot;$(SentryCLI)&quot; dif upload</_SentryCLICommand>
<_SentryCLICommand Condition="'$(SentryCLIOptions.Trim())' != ''">$(_SentryCLICommand) $(SentryCLIOptions.Trim())</_SentryCLICommand>
<_SentryCLICommand Condition="'$(SentryUploadSources)' == 'true'">$(_SentryCLICommand) --include-sources</_SentryCLICommand>
<_SentryCLICommand>$(_SentryCLICommand) $(IntermediateOutputPath)</_SentryCLICommand>
Expand All @@ -130,4 +132,35 @@

</Target>

<!-- Upload sources to Sentry after the build, if we didn't upload them with the symbols. -->
<Target Name="UploadSourcesToSentry" AfterTargets="Build;UploadSymbolsToSentry" DependsOnTargets="PrepareSentryCLI"
Condition="'$(SentryUploadSources)' == 'true' And '$(SentryUploadSymbols)' != 'true' And '$(SentryCLI)' != ''">

<Message Importance="High" Condition="'$(SentryUploadSources)' == 'true'"
Text="Preparing to upload sources to Sentry for $(MSBuildProjectName) ($(Configuration)/$(TargetFramework))" />

<PropertyGroup>
<_SentryDebugInfoFile>@(IntermediateAssembly->'$(IntermediateOutputPath)%(FileName).pdb')</_SentryDebugInfoFile>
<_SentryDebugInfoFile Condition="!Exists('$(_SentryDebugInfoFile)')">@(IntermediateAssembly->'$(IntermediateOutputPath)%(FileName)%(Extension)')</_SentryDebugInfoFile>
<_SentrySourceBundle>@(IntermediateAssembly->'$(IntermediateOutputPath)%(FileName).src.zip')</_SentrySourceBundle>
</PropertyGroup>

<PropertyGroup>
<_SentryCLICommand>&quot;$(SentryCLI)&quot; dif bundle-sources $(_SentryDebugInfoFile)</_SentryCLICommand>
</PropertyGroup>
<Exec Command="$(_SentryCLICommand)" IgnoreExitCode="true" ContinueOnError="WarnAndContinue" />

<PropertyGroup>
<_SentryCLICommand>&quot;$(SentryCLI)&quot; dif upload</_SentryCLICommand>
<_SentryCLICommand Condition="'$(SentryCLIOptions.Trim())' != ''">$(_SentryCLICommand) $(SentryCLIOptions.Trim())</_SentryCLICommand>
<_SentryCLICommand>$(_SentryCLICommand) $(_SentrySourceBundle)</_SentryCLICommand>
</PropertyGroup>
<Exec Command="$(_SentryCLICommand)" IgnoreExitCode="true" ContinueOnError="WarnAndContinue" Condition="Exists('$(_SentrySourceBundle)')">
<Output TaskParameter="ExitCode" PropertyName="_SentryCLIExitCode" />
</Exec>

<Warning Condition="'$(_SentryCLIExitCode)' != '0'" Text="Sentry CLI could not upload sources." />

</Target>

</Project>