Skip to content

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

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

Open
jamescrosswell opened this issue May 19, 2025 · 0 comments

Comments

@jamescrosswell
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

1 participant