Skip to content

Commit b47c4db

Browse files
chore: Added IsNet8OrGreater build prop for readablility (#4275)
Resolves #4203: - #4203
1 parent ac3db8d commit b47c4db

File tree

7 files changed

+22
-16
lines changed

7 files changed

+22
-16
lines changed

Directory.Build.props

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,12 @@
4141
</PropertyGroup>
4242

4343
<!--
44-
Note: The following platform-specific properties need to be set in both Directory.Build.props and DirectoryBuild.targets.
44+
Note: The following platform-specific properties need to be set in both Directory.Build.props and Directory.Build.targets.
4545
TODO: Figure out how to consolidate to a single location.
46-
- Directory.Build.props will get imported at the beginning of the project files, so sets properties that are
47-
prerequisites for the build and can be overriden in the project files.
48-
- Directory.Build.targets will get imported at the end of the project files, so can be used to run common custom
49-
tasks or ultimately override properties set in Directory.Build.props or the project files.
46+
Note: I don't believe we need to set these in the Directory.Build.targets file.
47+
See: https://github.com/jamescrosswell/msbuild-test-4275
5048
-->
51-
<PropertyGroup>
49+
<PropertyGroup Condition="'$(TargetFramework)' != ''">
5250
<TargetPlatformIdentifier>$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)'))</TargetPlatformIdentifier>
5351
<SupportedOSPlatformVersion Condition="'$(TargetPlatformIdentifier)' == 'ios'">12.2</SupportedOSPlatformVersion>
5452
<SupportedOSPlatformVersion Condition="'$(TargetPlatformIdentifier)' == 'maccatalyst'">15.0</SupportedOSPlatformVersion>
@@ -111,9 +109,6 @@
111109
<InternalsVisibleTo Include="DynamicProxyGenAssembly2" PublicKey="0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7" />
112110
</ItemGroup>
113111

114-
<!-- Helpful properties used elsewhere -->
115-
<PropertyGroup>
116-
<TargetFrameworkVersion>$([MSBuild]::GetTargetFrameworkVersion($(TargetFramework)))</TargetFrameworkVersion>
117-
<TargetFrameworkIsNet9OrGreater Condition="$([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), 9.0))">true</TargetFrameworkIsNet9OrGreater>
118-
</PropertyGroup>
112+
<!-- Definitions that we want available both for local developement and building transitively -->
113+
<Import Project="$(MSBuildThisFileDirectory)\src\Sentry\buildTransitive\Sentry.props" />
119114
</Project>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
</None>
7777
</ItemGroup>
7878

79-
<Target Name="CleanNativeSDK" BeforeTargets="CoreClean" Condition="'$(TargetFramework)' == 'net8.0' or '$(TargetFramework)' == 'net9.0'">
79+
<Target Name="CleanNativeSDK" BeforeTargets="CoreClean" Condition="'$(_SentryIsNet8OrGreater)' == 'true'">
8080
<Message Text="Inside Custom Clean" Importance="high"/>
8181
<RemoveDir Directories="$(SentryNativeOutputDirectory)" />
8282
<RemoveDir Directories="$(SentryNativeSourceDirectory)build" />
@@ -86,7 +86,7 @@
8686
built already on each native platform and fetched for the final .net build. -->
8787
<Target Name="_BuildSentryNativeSDK"
8888
BeforeTargets="DispatchToInnerBuilds;BeforeBuild"
89-
Condition="('$(TargetFramework)' == 'net8.0' or '$(TargetFramework)' == 'net9.0') and '$(CI)' != 'true'"
89+
Condition="'$(_SentryIsNet8OrGreater)' == 'true' and '$(CI)' != 'true'"
9090
Inputs="$(SentryNativeBuildInputs)"
9191
Outputs="$(SentryNativeBuildOutputs)">
9292
<!-- We want a "-Clean" because if the build script changes, previous cmake cache may contain invalid defines. -->

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
<PropertyGroup>
2222
<!-- net8.0 or greater -->
23-
<FrameworkSupportsNative Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0')) and ('$(OutputType)' == 'Exe' or '$(OutputType)' == 'WinExe')">true</FrameworkSupportsNative>
23+
<FrameworkSupportsNative Condition="'$(_SentryIsNet8OrGreater)' == 'true' and ('$(OutputType)' == 'Exe' or '$(OutputType)' == 'WinExe')">true</FrameworkSupportsNative>
2424
<!-- Make it opt-out -->
2525
<FrameworkSupportsNative Condition="'$(SentryNative)' == 'false' or '$(SentryNative)' == 'disable'">false</FrameworkSupportsNative>
2626
</PropertyGroup>

src/Sentry/Sentry.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,8 @@
194194
</ItemGroup>
195195

196196
<ItemGroup>
197+
<None Include="buildTransitive\Sentry.props" Pack="true" PackagePath="buildTransitive\Sentry.props" />
198+
<None Include="buildTransitive\Sentry.props" Pack="true" PackagePath="build\Sentry.props" />
197199
<None Include="buildTransitive\Sentry.targets" Pack="true" PackagePath="buildTransitive\Sentry.targets" />
198200
<None Include="buildTransitive\Sentry.targets" Pack="true" PackagePath="build\Sentry.targets" />
199201
<None Include="buildTransitive\Sentry.SourceGenerators.targets" Pack="true" PackagePath="buildTransitive\Sentry.SourceGenerators.targets" />
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<!-- Helpful properties used elsewhere -->
4+
<PropertyGroup Condition="'$(TargetFramework)' != ''">
5+
<_SentryTargetFrameworkVersion>$([MSBuild]::GetTargetFrameworkVersion($(TargetFramework)))</_SentryTargetFrameworkVersion>
6+
<_SentryIsNet8OrGreater>$([MSBuild]::VersionGreaterThanOrEquals($(_SentryTargetFrameworkVersion), 8.0))</_SentryIsNet8OrGreater>
7+
<_SentryIsNet9OrGreater>$([MSBuild]::VersionGreaterThanOrEquals($(_SentryTargetFrameworkVersion), 9.0))</_SentryIsNet9OrGreater>
8+
</PropertyGroup>
9+
</Project>

test/Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
<!-- Visual tests need net9.0+ mobile and are flaky when using the headless runner on CI -->
1616
<EnableMauiDeviceTestVisualRunner>false</EnableMauiDeviceTestVisualRunner>
17-
<EnableMauiDeviceTestVisualRunner Condition="'$(TargetFrameworkIsNet9OrGreater)' == 'true' AND '$(PlatformIsMobile)' == 'true' AND '$(ContinuousIntegrationBuild)' != 'true'">true</EnableMauiDeviceTestVisualRunner>
17+
<EnableMauiDeviceTestVisualRunner Condition="'$(_SentryIsNet9OrGreater)' == 'true' AND '$(PlatformIsMobile)' == 'true' AND '$(ContinuousIntegrationBuild)' != 'true'">true</EnableMauiDeviceTestVisualRunner>
1818
</PropertyGroup>
1919
<!--
2020
Workaround for Verify issue with scrubbing when running in Rider on Windows.

test/Sentry.Maui.Device.TestApp/Sentry.Maui.Device.TestApp.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103
<ProjectReference Include="..\Sentry.Tests\Sentry.Tests.csproj"/>
104104
<ProjectReference Include="..\Sentry.Extensions.Logging.Tests\Sentry.Extensions.Logging.Tests.csproj"/>
105105
<ProjectReference Include="..\Sentry.Maui.Tests\Sentry.Maui.Tests.csproj"/>
106-
<ProjectReference Include="..\Sentry.Maui.CommunityToolkit.Mvvm.Tests\Sentry.Maui.CommunityToolkit.Mvvm.Tests.csproj" Condition="'$(TargetFrameworkIsNet9OrGreater)' == 'true'"/>
106+
<ProjectReference Include="..\Sentry.Maui.CommunityToolkit.Mvvm.Tests\Sentry.Maui.CommunityToolkit.Mvvm.Tests.csproj" Condition="'$(_SentryIsNet9OrGreater)' == 'true'"/>
107107
</ItemGroup>
108108

109109
</Project>

0 commit comments

Comments
 (0)