Skip to content

fix: Clean repo builds no longer fail when building native #4366

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

Merged
merged 7 commits into from
Jul 18, 2025
Merged
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
24 changes: 19 additions & 5 deletions src/Sentry/Platforms/Native/Sentry.Native.targets
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<Project>

<PropertyGroup>
<SentryNativeSourceDirectory>..\..\modules\sentry-native\</SentryNativeSourceDirectory>
<SentryNativeSourceDirectory>$(MSBuildThisFileDirectory)..\..\..\..\modules\sentry-native\</SentryNativeSourceDirectory>
<SentryNativeLibraryName>sentry-native</SentryNativeLibraryName>
<SentryNativeBuildScript>../../scripts/build-sentry-native.ps1</SentryNativeBuildScript>
<SentryNativeBuildInputs>../../.git/modules/modules/sentry-native/HEAD;$(MSBuildThisFileDirectory)Sentry.Native.targets;$(SentryNativeBuildScript)</SentryNativeBuildInputs>
<SentryNativeBuildScript>$(MSBuildThisFileDirectory)..\..\..\..\scripts\build-sentry-native.ps1</SentryNativeBuildScript>
<SentryNativeBuildInputs>$(MSBuildThisFileDirectory)..\..\..\..\.git\modules\modules\sentry-native/HEAD;$(MSBuildThisFileDirectory)Sentry.Native.targets;$(SentryNativeBuildScript)</SentryNativeBuildInputs>
<SentryNativeOutputDirectory>$(MSBuildThisFileDirectory)sentry-native\</SentryNativeOutputDirectory>
<!-- List of runtime identifiers: https://github.com/dotnet/runtime/blob/main/src/libraries/Microsoft.NETCore.Platforms/src/runtime.json -->
<NativeLibRelativePath-win-x64>win-x64</NativeLibRelativePath-win-x64>
Expand Down Expand Up @@ -85,11 +85,25 @@
<!-- Build the Sentry Native SDK (this only runs on local machines because in CI we expect the SDK to be
built already on each native platform and fetched for the final .net build. -->
<Target Name="_BuildSentryNativeSDK"
BeforeTargets="DispatchToInnerBuilds;BeforeBuild"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "when" now gets resolved by this target being "clamped" by the two new ones.

Condition="'$(_SentryIsNet8OrGreater)' == 'true' and '$(CI)' != 'true'"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition needs to be added to the new one's as '$(_SentryIsNet8OrGreater)' == 'true' does not resolve due to TF being removed.

Inputs="$(SentryNativeBuildInputs)"
Outputs="$(SentryNativeBuildOutputs)">
<!-- We want a "-Clean" because if the build script changes, previous cmake cache may contain invalid defines. -->
<Exec Command="pwsh $(SentryNativeBuildScript) -Clean" />
</Target>

<!-- We want to build the sentry-native only once, BEFORE building TFM specific verions of the SDK -->
<!-- How to run a target exactly once: https://learn.microsoft.com/visualstudio/msbuild/run-target-exactly-once-->
<Target Name="_BuildSentryNativeSDKBeforeOuterBuild"
Condition="'$(_SentryIsNet8OrGreater)' == 'true' and '$(CI)' != 'true'"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have to keep the condition on the "outer" target as the TF gets removed on line 108

DependsOnTargets="_BuildSentryNativeSDK"
BeforeTargets="DispatchToInnerBuilds">
</Target>

<Target Name="_BuildSentryNativeSDKBeforeInnerBuild"
Condition="'$(_SentryIsNet8OrGreater)' == 'true' and '$(CI)' != 'true'"
BeforeTargets="BeforeBuild">
<MSBuild Projects="$(MSBuildProjectFullPath)"
Targets="_BuildSentryNativeSDK"
RemoveProperties="TargetFramework" />
</Target>
</Project>
Loading