Skip to content
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

Sdk.Targets - Use GetTargetFrameworkIdentifier to identify framework. #19

Open
Foxtrek64 opened this issue Oct 28, 2024 · 0 comments
Open

Comments

@Foxtrek64
Copy link
Contributor

Foxtrek64 commented Oct 28, 2024

Example Input:

<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

    <PropertyGroup>
        <NetFx>net461</NetFx>
        <NetStandard>netstandard2.0</NetStandard>
        <NetCoreApp>netcoreapp3.0</NetCoreApp>
        <NetCore>net5.0</NetCore>
    </PropertyGroup>

    <Target Name="MyTarget">
        <Message Importance="high" Text="$(NetFx) = $([MSBuild]::GetTargetFrameworkIdentifier($(NetFx)))" />
        <Message Importance="high" Text="$(NetStandard) = $([MSBuild]::GetTargetFrameworkIdentifier($(NetStandard)))" />
        <Message Importance="high" Text="$(NetCoreApp) = $([MSBuild]::GetTargetFrameworkIdentifier($(NetCoreApp)))" />
        <Message Importance="high" Text="$(NetCore) = $([MSBuild]::GetTargetFrameworkIdentifier($(NetCore)))" />
    </Target>

</Project>

Example Output:

net461 = .NETFramework
netstandard2.0 = .NETStandard
netcoreapp3.0 = .NETCoreApp
net5.0 = .NETCoreApp

API Proposal:

<PropertyGroup>
  <RemoraFrameworkIdentifier>$([MSBuild]::GetTargetFrameworkIdentifier($TargetFramework))</RemoraFrameworkIdentifier>
  <IsNET>$(RemoraFrameworkIdentifier) == '.NETCoreApp'</IsNET>
  <IsNETCore>$(RemoraFrameworkIdentifier) == '.NETCoreApp'</IsNETCore>
  <IsNETStandard>$(RemoraFrameworkIdentifier) == '.NETStandard'</IsNETStandard>
  <IsNETFramework>$(RemoraFrameworkIdentifier) == '.NETFramework'</IsNETFramework>
  <IsRunnableTarget>$(RemoraFrameworkIdentifier) != '.NETStandard'</IsRunnableTarget>
</PropertyGroup>

Drawbacks:
We lose differentiation between IsNET and IsNETCore. I'm not too entirely sure what IsNET is used for though - MSBuild doesn't appear to differentiate between netcoreapp3.0 and net5. Additionally, it doesn't appear to be used within the SDK at all. Is this intended for use by consumers of the SDK?

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

No branches or pull requests

1 participant