forked from yanw/App_win_iot_V2.0
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
246 lines
17 KiB
246 lines
17 KiB
<?xml version="1.0" encoding="utf-8"?>
|
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
|
|
<ItemGroup Condition="$(Language) == 'C#' and $(SentryImplicitUsings) != 'false' and ($(ImplicitUsings) == 'enable' or $(ImplicitUsings) == 'true')">
|
|
<Using Include="Sentry" />
|
|
</ItemGroup>
|
|
|
|
<PropertyGroup>
|
|
<SentryAttributesFile>Sentry.Attributes$(MSBuildProjectExtension.Replace('proj', ''))</SentryAttributesFile>
|
|
</PropertyGroup>
|
|
|
|
<Target Name="WriteSentryAttributes"
|
|
Condition="$(Language) == 'VB' or $(Language) == 'C#' or $(Language) == 'F#'"
|
|
BeforeTargets="BeforeCompile;CoreCompile"
|
|
Inputs="$(MSBuildAllProjects)"
|
|
Outputs="$(IntermediateOutputPath)$(SentryAttributesFile)">
|
|
<PropertyGroup>
|
|
<SentryAttributesFilePath>$(IntermediateOutputPath)$(SentryAttributesFile)</SentryAttributesFilePath>
|
|
</PropertyGroup>
|
|
<ItemGroup>
|
|
<SentryAttributes Include="System.Reflection.AssemblyMetadata">
|
|
<_Parameter1>Sentry.ProjectDirectory</_Parameter1>
|
|
<_Parameter2>$(ProjectDir)</_Parameter2>
|
|
</SentryAttributes>
|
|
<!-- Ensure not part of Compile, as a workaround for https://github.com/dotnet/sdk/issues/114 -->
|
|
<Compile Remove="$(SentryAttributesFilePath)" />
|
|
</ItemGroup>
|
|
<WriteCodeFragment AssemblyAttributes="@(SentryAttributes)" Language="$(Language)" OutputFile="$(SentryAttributesFilePath)">
|
|
<Output Condition="$(Language) != 'F#'" TaskParameter="OutputFile" ItemName="Compile" />
|
|
<Output Condition="$(Language) == 'F#'" TaskParameter="OutputFile" ItemName="CompileBefore" />
|
|
<Output TaskParameter="OutputFile" ItemName="FileWrites" />
|
|
</WriteCodeFragment>
|
|
</Target>
|
|
|
|
<Target Name="CheckSentryCLI" AfterTargets="Build" Condition="'$(InnerTargets)' == ''">
|
|
<PropertyGroup>
|
|
<!-- Set defaults for the Sentry properties. -->
|
|
<SentryUploadSymbols Condition="'$(SentryUploadSymbols)' == ''">false</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.
|
|
We're explicitly skipping uploads for Sentry projects because they interfere with CLI integration test asserts. -->
|
|
<UseSentryCLI Condition="
|
|
'$(UseSentryCLI)' == ''
|
|
and ('$(SentryUploadSymbols)' == 'true' or '$(SentryUploadSources)' == 'true' or $(SentryUploadAndroidProguardMapping) == 'true')
|
|
and '$(MSBuildProjectName)' != 'Sentry'
|
|
and !$(MSBuildProjectName.StartsWith('Sentry.'))">true</UseSentryCLI>
|
|
</PropertyGroup>
|
|
</Target>
|
|
|
|
<Target Name="PrepareSentryCLI" AfterTargets="CheckSentryCLI" Condition="'$(UseSentryCLI)' == 'true'">
|
|
<!--
|
|
If Sentry was added via PackageReference, PkgSentry will already be set to the path of the Sentry nuget package.
|
|
However, older-style projects using packages.config will need us to resolve the path manually.
|
|
-->
|
|
<PropertyGroup Condition="'$(SentryCLIDirectory)' == '' And '$(PkgSentry)' == ''">
|
|
<PkgSentry Condition="$([System.String]::new('%(Reference.Identity)').StartsWith('Sentry,'))">$([System.IO.Directory]::GetParent(%(Reference.HintPath)).Parent.Parent.FullName)</PkgSentry>
|
|
</PropertyGroup>
|
|
|
|
<!-- Sentry CLI comes from the Sentry Nuget package when installed. -->
|
|
<PropertyGroup Condition="'$(SentryCLIDirectory)' == '' And '$(PkgSentry)' != ''">
|
|
<SentryCLIDirectory>$(PkgSentry)\tools\</SentryCLIDirectory>
|
|
</PropertyGroup>
|
|
|
|
<!--
|
|
Choose the correct Sentry CLI executable depending on OS platform and architecture.
|
|
For Windows on Arm64, we'll use the X64 build for now (which should run via emulation).
|
|
Switch to a Windows Arm64 build when available. See https://github.com/getsentry/sentry-cli/issues/1426
|
|
-->
|
|
<PropertyGroup Condition="'$(SentryCLI)' == '' And '$(SentryCLIDirectory)' != ''">
|
|
<_OSArchitecture>$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)</_OSArchitecture>
|
|
<SentryCLI Condition="$([MSBuild]::IsOSPlatform('OSX')) And $(_OSArchitecture) == 'Arm64'">$(SentryCLIDirectory)sentry-cli-Darwin-arm64</SentryCLI>
|
|
<SentryCLI Condition="$([MSBuild]::IsOSPlatform('OSX')) And $(_OSArchitecture) == 'X64'">$(SentryCLIDirectory)sentry-cli-Darwin-x86_64</SentryCLI>
|
|
<SentryCLI Condition="$([MSBuild]::IsOSPlatform('Linux')) And $(_OSArchitecture) == 'Arm64'">$(SentryCLIDirectory)sentry-cli-Linux-aarch64</SentryCLI>
|
|
<SentryCLI Condition="$([MSBuild]::IsOSPlatform('Linux')) And $(_OSArchitecture) == 'X86'">$(SentryCLIDirectory)sentry-cli-Linux-i686</SentryCLI>
|
|
<SentryCLI Condition="$([MSBuild]::IsOSPlatform('Linux')) And $(_OSArchitecture) == 'X64'">$(SentryCLIDirectory)sentry-cli-Linux-x86_64</SentryCLI>
|
|
<SentryCLI Condition="$([MSBuild]::IsOSPlatform('Windows')) And $(_OSArchitecture) == 'Arm64'">$(SentryCLIDirectory)sentry-cli-Windows-x86_64.exe</SentryCLI>
|
|
<SentryCLI Condition="$([MSBuild]::IsOSPlatform('Windows')) And $(_OSArchitecture) == 'X86'">$(SentryCLIDirectory)sentry-cli-Windows-i686.exe</SentryCLI>
|
|
<SentryCLI Condition="$([MSBuild]::IsOSPlatform('Windows')) And $(_OSArchitecture) == 'X64'">$(SentryCLIDirectory)sentry-cli-Windows-x86_64.exe</SentryCLI>
|
|
<SentryCLI Condition="!Exists('$(SentryCLI)')"/>
|
|
</PropertyGroup>
|
|
|
|
<!--
|
|
The Sentry configuration can be set manually in MSBuild properties if desired.
|
|
Otherwise the default configuration will be used, as reported by "sentry-cli info".
|
|
The defaults can be set either via config file, or environment variables, per: https://docs.sentry.io/product/cli/configuration/
|
|
-->
|
|
<PropertyGroup>
|
|
<SentryCLIBaseOptions Condition="'$(SentryApiKey)' != ''">$(SentryCLIBaseOptions) --api-key $(SentryApiKey)</SentryCLIBaseOptions>
|
|
<SentryCLIBaseOptions Condition="'$(SentryAuthToken)' != ''">$(SentryCLIBaseOptions) --auth-token $(SentryAuthToken)</SentryCLIBaseOptions>
|
|
<SentryCLIBaseOptions Condition="'$(SentryUrl)' != ''">$(SentryCLIBaseOptions) --url $(SentryUrl)</SentryCLIBaseOptions>
|
|
<SentryCLIBaseCommand>"$(SentryCLI)"</SentryCLIBaseCommand>
|
|
<SentryCLIBaseCommand Condition="'$(SentryCLIBaseOptions.Trim())' != ''">$(SentryCLIBaseCommand) $(SentryCLIBaseOptions.Trim())</SentryCLIBaseCommand>
|
|
|
|
<SentryCLIUploadOptions Condition="'$(SentryOrg)' != ''">$(SentryCLIUploadOptions) --org $(SentryOrg)</SentryCLIUploadOptions>
|
|
<SentryCLIUploadOptions Condition="'$(SentryProject)' != ''">$(SentryCLIUploadOptions) --project $(SentryProject)</SentryCLIUploadOptions>
|
|
<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)' != ''">
|
|
<_SentryCLICommand>$(SentryCLIBaseCommand) info</_SentryCLICommand>
|
|
<_SentryCLICommand Condition="'$(SentryOrg)' != '' And '$(SentryProject)' != ''">$(_SentryCLICommand) --no-defaults</_SentryCLICommand>
|
|
</PropertyGroup>
|
|
<Exec Condition="'$(SentryCLI)' != ''" Command="$(_SentryCLICommand)" IgnoreExitCode="true" ConsoleToMsBuild="true" StandardOutputImportance="Low">
|
|
<Output TaskParameter="ExitCode" PropertyName="_SentryCLIExitCode" />
|
|
<Output TaskParameter="ConsoleOutput" PropertyName="_SentryCLIOutput" />
|
|
</Exec>
|
|
|
|
<PropertyGroup Condition="'$(_SentryCLIExitCode)' != '0'">
|
|
<_SentryCLIRequestFailed Condition="$(_SentryCLIOutput.Contains('API request failed'))">true</_SentryCLIRequestFailed>
|
|
</PropertyGroup>
|
|
<Warning Condition="'$(_SentryCLIRequestFailed)' != ''"
|
|
Text="Sentry API request failed. Either the authentication info is invalid, or the Sentry server could not be reached." />
|
|
|
|
<Message Importance="High" Condition="'$(_SentryCLIExitCode)' != '0' And '$(_SentryCLIRequestFailed)' == ''"
|
|
Text="The Sentry CLI is not fully configured with authentication, organization, and project." />
|
|
<PropertyGroup Condition="'$(_SentryCLIExitCode)' != '0'">
|
|
<SentryCLI />
|
|
</PropertyGroup>
|
|
|
|
<Warning Condition="'$(SentryUploadSources)' == 'true' And '$(EmbedAllSources)' == 'true'"
|
|
Text="Both SentryUploadSources and EmbedAllSources are enabled. Disabling SentryUploadSources." />
|
|
<PropertyGroup Condition="'$(SentryUploadSources)' == 'true' And '$(EmbedAllSources)' == 'true'">
|
|
<SentryUploadSources>false</SentryUploadSources>
|
|
</PropertyGroup>
|
|
|
|
</Target>
|
|
|
|
<!-- Native AOT publishing
|
|
Note 1: While '_IsPublishing' looks a bit "private", it's also OK if it suddenly stops working and this step runs anyway.
|
|
See https://github.com/dotnet/sdk/issues/26324#issuecomment-1169236993
|
|
Note 2: Target framework conditions should be kept synchronized with src/Sentry/Platforms/Native/buildTransitive/Sentry.Native.targets -->
|
|
<PropertyGroup Condition="
|
|
$(TargetFramework.StartsWith('net8'))
|
|
and '$(PublishDir)' != ''
|
|
and '$(PublishAot)' == 'true'
|
|
and '$(_IsPublishing)' == 'true'
|
|
and $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) != 'ios'
|
|
and $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) != 'maccatalyst'">
|
|
<SentryCLIUploadNativeAOT>true</SentryCLIUploadNativeAOT>
|
|
<SentryCLIUploadDirectory>$(PublishDir)</SentryCLIUploadDirectory>
|
|
<!-- We must run after "_CopyAotSymbols" (not "Publish"), because that is the one that actually copies debug symbols to the publish directory. -->
|
|
<!-- See also https://github.com/dotnet/runtime/blob/v8.0.0/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Publish.targets#L100 -->
|
|
<SentryCLIUploadAfterTargets>_CopyAotSymbols</SentryCLIUploadAfterTargets>
|
|
</PropertyGroup>
|
|
<ItemGroup Condition="'$(SentryCLIUploadNativeAOT)' == 'true'">
|
|
<SentryCLIUploadSymbolType Include="pdb" />
|
|
<SentryCLIUploadSymbolType Include="dsym" />
|
|
<SentryCLIUploadSymbolType Include="elf" />
|
|
</ItemGroup>
|
|
|
|
<!-- "Standard" managed build -->
|
|
<PropertyGroup Condition="'$(SentryCLIUploadNativeAOT)' != 'true'">
|
|
<SentryCLIUploadNativeAOT>false</SentryCLIUploadNativeAOT>
|
|
<SentryCLIUploadDirectory>$(OutputPath)</SentryCLIUploadDirectory>
|
|
<SentryCLIUploadAfterTargets>Build</SentryCLIUploadAfterTargets>
|
|
</PropertyGroup>
|
|
<ItemGroup Condition="'$(SentryCLIUploadNativeAOT)' != 'true'">
|
|
<SentryCLIUploadSymbolType Include="pdb" />
|
|
<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 $(SentryCLIUploadItems)" />
|
|
<Exec
|
|
Condition="'$(SentryUploadSymbols)' == 'true' and '$(SentryUploadSources)' == 'true'"
|
|
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 $(SentryCLIUploadItems)" />
|
|
<Exec
|
|
Condition="'$(SentryUploadSymbols)' == 'true' and '$(SentryUploadSources)' != 'true'"
|
|
Command="$(SentryCLIDebugFilesUploadCommand) @(SentryCLIUploadSymbolType -> '-t %(Identity)', ' ') $(SentryCLIUploadItems)"
|
|
IgnoreExitCode="true" ContinueOnError="WarnAndContinue">
|
|
<Output TaskParameter="ExitCode" PropertyName="_SentryCLIExitCode" />
|
|
</Exec>
|
|
<!-- } else if (!UploadSymbols && UploadSources) { -->
|
|
<PropertyGroup>
|
|
<SentryCLIDebugInfoFile Condition="'$(NativeBinary)' != ''">$(NativeBinary)$(NativeSymbolExt)</SentryCLIDebugInfoFile>
|
|
<SentryCLIDebugInfoFile Condition="'$(NativeBinary)' == '' or !Exists('$(SentryCLIDebugInfoFile)')">@(IntermediateAssembly->'$(SentryCLIUploadDirectory)%(FileName).pdb')</SentryCLIDebugInfoFile>
|
|
<SentryCLIDebugInfoFile Condition="!Exists('$(SentryCLIDebugInfoFile)')">@(IntermediateAssembly->'$(SentryCLIUploadDirectory)%(FileName)%(Extension)')</SentryCLIDebugInfoFile>
|
|
<SentryCLIUploadSourcesDirectory>$([System.IO.Path]::GetDirectoryName('$(SentryCLIDebugInfoFile)'))</SentryCLIUploadSourcesDirectory>
|
|
</PropertyGroup>
|
|
<Message Importance="High"
|
|
Condition="'$(SentryUploadSymbols)' != 'true' and '$(SentryUploadSources)' == 'true'"
|
|
Text="Preparing upload to Sentry for project '$(MSBuildProjectName)' ($(Configuration)/$(TargetFramework)): collecting source code referenced by $(SentryCLIDebugInfoFile)" />
|
|
<Exec
|
|
Condition="'$(SentryUploadSymbols)' != 'true' and '$(SentryUploadSources)' == 'true'"
|
|
Command=""$(SentryCLI)" debug-files bundle-sources $(SentryCLIDebugInfoFile) " IgnoreExitCode="true" ContinueOnError="WarnAndContinue">
|
|
<Output TaskParameter="ExitCode" PropertyName="_SentryCLIExitCode" />
|
|
</Exec>
|
|
<Warning Condition="'$(_SentryCLIExitCode)' != '0'" Text="Sentry CLI could not upload debug files." />
|
|
<Exec
|
|
Condition="'$(SentryUploadSymbols)' != 'true' and '$(SentryUploadSources)' == 'true' and '$(_SentryCLIExitCode)' == '0'"
|
|
Command="$(SentryCLIDebugFilesUploadCommand) -t sourcebundle $(SentryCLIUploadSourcesDirectory)"
|
|
IgnoreExitCode="true" ContinueOnError="WarnAndContinue">
|
|
<Output TaskParameter="ExitCode" PropertyName="_SentryCLIExitCode" />
|
|
</Exec>
|
|
<!-- } -->
|
|
<Warning Condition="'$(_SentryCLIExitCode)' != '0'" Text="Sentry CLI could not upload debug files." />
|
|
</Target>
|
|
|
|
<!-- Upload Android Proguard mapping file to Sentry after the build. -->
|
|
<Target Name="UploadAndroidProguardMappingFileToSentry" AfterTargets="Build" DependsOnTargets="PrepareSentryCLI"
|
|
Condition="'$(SentryCLI)' != '' and '$(SentryUploadAndroidProguardMapping)' == 'true' And '$(AndroidProguardMappingFile)' != ''">
|
|
|
|
<Message Importance="High" Text="Preparing to upload Android Proguard mapping to Sentry for '$(MSBuildProjectName)': $(AndroidProguardMappingFile))" />
|
|
|
|
<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>
|
|
|
|
<Import Condition="'$(MSBuildProjectName)' != 'Sentry' and !$(MSBuildProjectName.StartsWith('Sentry.')) and '$(IsSentryTestProject)' == ''" Project="$(MSBuildThisFileDirectory)Sentry.Native.targets"/>
|
|
</Project>
|
|
|