Skip to content

Commit f1341ed

Browse files
authored
fix: Clean repo builds no longer fail when building native (#4366)
1 parent 6785f8e commit f1341ed

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

src/Sentry/Platforms/Native/Sentry.Native.targets

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<Project>
22

33
<PropertyGroup>
4-
<SentryNativeSourceDirectory>..\..\modules\sentry-native\</SentryNativeSourceDirectory>
4+
<SentryNativeSourceDirectory>$(MSBuildThisFileDirectory)..\..\..\..\modules\sentry-native\</SentryNativeSourceDirectory>
55
<SentryNativeLibraryName>sentry-native</SentryNativeLibraryName>
6-
<SentryNativeBuildScript>../../scripts/build-sentry-native.ps1</SentryNativeBuildScript>
7-
<SentryNativeBuildInputs>../../.git/modules/modules/sentry-native/HEAD;$(MSBuildThisFileDirectory)Sentry.Native.targets;$(SentryNativeBuildScript)</SentryNativeBuildInputs>
6+
<SentryNativeBuildScript>$(MSBuildThisFileDirectory)..\..\..\..\scripts\build-sentry-native.ps1</SentryNativeBuildScript>
7+
<SentryNativeBuildInputs>$(MSBuildThisFileDirectory)..\..\..\..\.git\modules\modules\sentry-native/HEAD;$(MSBuildThisFileDirectory)Sentry.Native.targets;$(SentryNativeBuildScript)</SentryNativeBuildInputs>
88
<SentryNativeOutputDirectory>$(MSBuildThisFileDirectory)sentry-native\</SentryNativeOutputDirectory>
99
<!-- List of runtime identifiers: https://github.com/dotnet/runtime/blob/main/src/libraries/Microsoft.NETCore.Platforms/src/runtime.json -->
1010
<NativeLibRelativePath-win-x64>win-x64</NativeLibRelativePath-win-x64>
@@ -85,11 +85,25 @@
8585
<!-- Build the Sentry Native SDK (this only runs on local machines because in CI we expect the SDK to be
8686
built already on each native platform and fetched for the final .net build. -->
8787
<Target Name="_BuildSentryNativeSDK"
88-
BeforeTargets="DispatchToInnerBuilds;BeforeBuild"
89-
Condition="'$(_SentryIsNet8OrGreater)' == 'true' and '$(CI)' != 'true'"
9088
Inputs="$(SentryNativeBuildInputs)"
9189
Outputs="$(SentryNativeBuildOutputs)">
9290
<!-- We want a "-Clean" because if the build script changes, previous cmake cache may contain invalid defines. -->
9391
<Exec Command="pwsh $(SentryNativeBuildScript) -Clean" />
9492
</Target>
93+
94+
<!-- We want to build the sentry-native only once, BEFORE building TFM specific verions of the SDK -->
95+
<!-- How to run a target exactly once: https://learn.microsoft.com/visualstudio/msbuild/run-target-exactly-once-->
96+
<Target Name="_BuildSentryNativeSDKBeforeOuterBuild"
97+
Condition="'$(_SentryIsNet8OrGreater)' == 'true' and '$(CI)' != 'true'"
98+
DependsOnTargets="_BuildSentryNativeSDK"
99+
BeforeTargets="DispatchToInnerBuilds">
100+
</Target>
101+
102+
<Target Name="_BuildSentryNativeSDKBeforeInnerBuild"
103+
Condition="'$(_SentryIsNet8OrGreater)' == 'true' and '$(CI)' != 'true'"
104+
BeforeTargets="BeforeBuild">
105+
<MSBuild Projects="$(MSBuildProjectFullPath)"
106+
Targets="_BuildSentryNativeSDK"
107+
RemoveProperties="TargetFramework" />
108+
</Target>
95109
</Project>

0 commit comments

Comments
 (0)