|
9 | 9 | <Description>.NET Bindings for the Sentry Cocoa SDK</Description> |
10 | 10 | <SentryCocoaCache>..\..\modules\sentry-cocoa\</SentryCocoaCache> |
11 | 11 | <SentryCocoaFrameworkHeaders>$(SentryCocoaCache)Sentry.framework\</SentryCocoaFrameworkHeaders> |
12 | | - <SentryCocoaFramework>$(SentryCocoaCache)Sentry-Dynamic.xcframework</SentryCocoaFramework> |
| 12 | + <SentryCocoaProperties>$([System.IO.File]::ReadAllText("$(MSBuildThisFileDirectory)../../modules/sentry-cocoa.properties"))</SentryCocoaProperties> |
| 13 | + <SentryCocoaVersion>$([System.Text.RegularExpressions.Regex]::Match($(SentryCocoaProperties), 'version\s*=\s*([^\s]+)').Groups[1].Value)</SentryCocoaVersion> |
| 14 | + <SentryCocoaFramework>$(SentryCocoaCache)Sentry-$(SentryCocoaVersion).xcframework</SentryCocoaFramework> |
13 | 15 | </PropertyGroup> |
14 | 16 |
|
15 | 17 | <!-- Build empty assemblies when not on macOS, to pass the solution build. --> |
|
46 | 48 | </ItemGroup> |
47 | 49 |
|
48 | 50 | <!-- Downloads and sets up the Cocoa SDK: dotnet msbuild /t:setupCocoaSDK src/Sentry.Bindings.Cocoa/Sentry.Bindings.Cocoa.csproj --> |
49 | | - <Target Name="SetupCocoaSDK" |
50 | | - Condition="$([MSBuild]::IsOSPlatform('OSX')) And !Exists('$(SentryCocoaCache)Sentry-Dynamic.xcframework')" |
51 | | - BeforeTargets="BeforeBuild"> |
52 | | - |
53 | | - <PropertyGroup> |
54 | | - <PropertiesContent>$([System.IO.File]::ReadAllText("../../modules/sentry-cocoa.properties"))</PropertiesContent> |
55 | | - <CocoaVersion>$([System.Text.RegularExpressions.Regex]::Match($(PropertiesContent), 'version\s*=\s*([^\s]+)').Groups[1].Value)</CocoaVersion> |
56 | | - </PropertyGroup> |
| 51 | + <Target Name="_SetupCocoaSDK" |
| 52 | + Condition="$([MSBuild]::IsOSPlatform('OSX')) And !Exists('$(SentryCocoaFramework)')"> |
57 | 53 |
|
58 | | - <Message Importance="High" Text="Setting up the Cocoa SDK version '$(CocoaVersion)'." /> |
| 54 | + <Message Importance="High" Text="Setting up the Cocoa SDK version '$(SentryCocoaVersion)'." /> |
59 | 55 |
|
60 | 56 | <!-- Clean cache if version does not exist to get rid of old versions --> |
61 | 57 | <RemoveDir |
62 | | - Condition="!Exists('$(SentryCocoaCache)Sentry-Dynamic-$(CocoaVersion).xcframework.zip')" |
| 58 | + Condition="!Exists('$(SentryCocoaFramework).zip')" |
63 | 59 | Directories="$(SentryCocoaCache)" /> |
64 | 60 |
|
65 | 61 | <!-- Create cache directory --> |
66 | 62 | <MakeDir Condition="!Exists('$(SentryCocoaCache)')" Directories="$(SentryCocoaCache)" /> |
67 | 63 |
|
68 | 64 | <!-- Download the Cocoa SDK as pre-built .xcframework --> |
69 | 65 | <Exec |
70 | | - Condition="!Exists('$(SentryCocoaCache)Sentry-Dynamic-$(CocoaVersion).xcframework.zip')" |
71 | | - Command="curl -L https://github.com/getsentry/sentry-cocoa/releases/download/$(CocoaVersion)/Sentry-Dynamic.xcframework.zip -o $(SentryCocoaCache)Sentry-Dynamic-$(CocoaVersion).xcframework.zip" /> |
| 66 | + Condition="!Exists('$(SentryCocoaFramework).zip')" |
| 67 | + Command="curl -L https://github.com/getsentry/sentry-cocoa/releases/download/$(SentryCocoaVersion)/Sentry-Dynamic.xcframework.zip -o $(SentryCocoaFramework).zip" /> |
72 | 68 |
|
73 | 69 | <Exec |
74 | | - Condition="!Exists('$(SentryCocoaCache)Sentry-Dynamic.xcframework')" |
75 | | - Command="unzip -o $(SentryCocoaCache)Sentry-Dynamic-$(CocoaVersion).xcframework.zip -d $(SentryCocoaCache)" /> |
| 70 | + Condition="Exists('$(SentryCocoaFramework).zip') and !Exists('$(SentryCocoaFramework)')" |
| 71 | + Command="unzip -o $(SentryCocoaFramework).zip -d $(SentryCocoaCache) && mv $(SentryCocoaCache)Sentry-Dynamic.xcframework $(SentryCocoaFramework)" /> |
76 | 72 |
|
77 | 73 | <!-- Make a copy of the header files before we butcher these to suite objective sharpie --> |
78 | 74 | <MakeDir Directories="$(SentryCocoaFrameworkHeaders)" /> |
79 | 75 | <ItemGroup> |
80 | | - <FilesToCopy Include="$(SentryCocoaCache)Sentry-Dynamic.xcframework\ios-arm64_arm64e\Sentry.framework\**\*" /> |
| 76 | + <FilesToCopy Include="$(SentryCocoaFramework)\ios-arm64_arm64e\Sentry.framework\**\*" /> |
81 | 77 | </ItemGroup> |
82 | 78 | <Copy SourceFiles="@(FilesToCopy)" |
83 | 79 | DestinationFolder="$(SentryCocoaFrameworkHeaders)%(RecursiveDir)" |
84 | 80 | SkipUnchangedFiles="true" /> |
85 | 81 | </Target> |
86 | 82 |
|
| 83 | + <!-- Setup exactly once: https://learn.microsoft.com/visualstudio/msbuild/run-target-exactly-once --> |
| 84 | + <Target Name="SetupCocoaSDKBeforeOuterBuild" DependsOnTargets="_SetupCocoaSDK" |
| 85 | + Condition="$([MSBuild]::IsOSPlatform('OSX')) And !Exists('$(SentryCocoaFramework)')" |
| 86 | + BeforeTargets="DispatchToInnerBuilds" /> |
| 87 | + |
| 88 | + <Target Name="SetupCocoaSDK" |
| 89 | + BeforeTargets="BeforeBuild" |
| 90 | + Condition="$([MSBuild]::IsOSPlatform('OSX')) And !Exists('$(SentryCocoaFramework)')"> |
| 91 | + <!-- Setup exactly once: https://learn.microsoft.com/visualstudio/msbuild/run-target-exactly-once --> |
| 92 | + <MSBuild Projects="$(MSBuildProjectFullPath)" Targets="_SetupCocoaSDK" RemoveProperties="TargetFramework" /> |
| 93 | + </Target> |
| 94 | + |
87 | 95 | <Target Name="CleanCocoaSDK" AfterTargets="Clean" Condition="$([MSBuild]::IsOSPlatform('OSX'))"> |
88 | 96 | <RemoveDir Directories="$(SentryCocoaCache)" ContinueOnError="true" /> |
89 | 97 | </Target> |
|
0 commit comments