Skip to content

Conditionally enabling Native support on net8.0 or later is confusing (or maybe broken) #4203

@jamescrosswell

Description

@jamescrosswell

I think there might be a problem with how/when we enable the Native SDK. According to the docs IsTargetFrameworkCompatible returns true if the "Candidate" (second argument) is compatible with the "Target" (first argument).

These seem to be reversed here:

<FrameworkSupportsNative Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0')) and ('$(OutputType)' == 'Exe' or '$(OutputType)' == 'WinExe')">true</FrameworkSupportsNative>

If they're not reversed, that IsTargetFrameworkCompatible function is just plain confusing (and thus error prone) and I think we should just avoid using it.

I had some issues with this elsewhere and added a more reliable (and understandable) way of doing minimum version checks:

<TargetFrameworkIsNet9OrGreater Condition="$([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), 9.0))">true</TargetFrameworkIsNet9OrGreater>

We could potentially add TargetFrameworkIsNet8OrGreater as well and use that to conditionally enable Native support instead.

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions