|
7 | 7 | <Import Project="$(MSBuildThisFileDirectory)..\src\Sentry.Bindings.Cocoa\buildTransitive\Sentry.Bindings.Cocoa.targets" |
8 | 8 | Condition="'$(OutputType)' == 'Exe' And ('$(TargetPlatformIdentifier)' == 'ios' Or '$(TargetPlatformIdentifier)' == 'maccatalyst')" /> |
9 | 9 | <Import Project="$(MSBuildThisFileDirectory)..\src\Sentry\Platforms\Native\buildTransitive\Sentry.Native.targets" /> |
| 10 | + |
| 11 | + <Target Name="GenerateSharedDsnConstant" |
| 12 | + BeforeTargets="BeforeCompile" |
| 13 | + Condition=" '$(SENTRY_DSN)' != '' and '$(PlatformIsMobile)' == 'true'"> |
| 14 | + |
| 15 | + <Message Text="Generating shared EnvironmentVariables.g.cs with embedded DSN..." Importance="High" /> |
| 16 | + |
| 17 | + <WriteLinesToFile |
| 18 | + File="$(MSBuildThisFileDirectory)EnvironmentVariables.g.cs" |
| 19 | + Lines=" |
| 20 | +// This file is auto-generated by a custom build target used in the Sentry Samples... in your own projects you should |
| 21 | +// specify the DSN either directly in code (in the file where you initialize Sentry) or via SENTRY_DSN environment |
| 22 | +// variable (for non-mobile projects - that won't work on Android, iOS, or MacCatalyst). |
| 23 | +namespace Sentry.Samples%3B |
| 24 | +
|
| 25 | +internal static class EnvironmentVariables |
| 26 | +{ |
| 27 | + /// <summary> |
| 28 | + /// To make things easier for the SDK maintainers we have a custom build target that writes the |
| 29 | + /// SENTRY_DSN environment variable into an EnvironmentVariables class that is available for mobile |
| 30 | + /// targets. This allows us to share one DSN defined in the ENV across desktop and mobile samples. |
| 31 | + /// Generally, you won't want to do this in your own mobile projects though - you should set the DSN |
| 32 | + /// in code as above |
| 33 | + /// </summary> |
| 34 | + internal const string Dsn = "$(SENTRY_DSN)"%3B |
| 35 | +} |
| 36 | +" |
| 37 | + Overwrite="true" /> |
| 38 | + </Target> |
| 39 | + |
| 40 | + <ItemGroup> |
| 41 | + <!-- Make sure all sample projects include the generated file --> |
| 42 | + <Compile Include="$(MSBuildThisFileDirectory)EnvironmentVariables.g.cs" Condition="Exists('$(MSBuildThisFileDirectory)EnvironmentVariables.g.cs')" /> |
| 43 | + <!-- Make sure all sample projects include any other shared files --> |
| 44 | + <Compile Include="$(MSBuildThisFileDirectory)SamplesShared.cs" /> |
| 45 | + |
| 46 | + <!-- Add shared global usings --> |
| 47 | + <Using Include="Sentry.Samples" /> |
| 48 | + </ItemGroup> |
| 49 | + |
10 | 50 | </Project> |
0 commit comments