NuGet - RID and TFM Examples

1.3k Views Asked by At

I've been reviewing the code for NuGet3 on GitHub, and I see several folder patterns in https://github.com/NuGet/NuGet3/blob/a5bc907d36ddaa8d4fa6c499e50d7ebf8993ed39/src/NuGet.Client/ManagedCodeConventions.cs related to expected folder structures within a NuGet package. However, I'm having a hard time finding any examples of these - specifically the rid and tfm values.

How can I know all the possible values for rid and tfm? I know they mean Runtime Identifier and Target Framework Moniker, but I don't really know what to do with that.

The documentation that I've seen never seems to deal with the topic directly or exhaustively.

2

There are 2 best solutions below

0
On

The target frameworks are currently hard coded within the NuGet source code. Whilst some of the target frameworks are documented on the NuGet website there are many which are not documented there. So as Jeff R already mentioned the best way to find the target frameworks is currently to look at the NuGet source code.

NuGet also has short identifiers for some of these frameworks (e.g. wp = WindowsPhone).

The runtime identifiers defined by Microsoft are available in the Microsoft.NETCore.Platforms NuGet package. Inside this NuGet package is a runtime.json file with the runtime identifiers:

{
    "runtimes": {
        "base": {
        },

        "any": {
            "#import": [ "base" ]
        },

        "win": {
            "#import": [ "any" ]
        },
        "win-x86": {
            "#import": [ "win" ]
        },
        "win-x64": {
            "#import": [ "win" ]
        },

        "win7": {
            "#import": [ "win" ]
        },
        "win7-x86": {
            "#import": [ "win7", "win-x86" ]
        },
        "win7-x64": {
            "#import": [ "win7", "win-x64" ]
        },

        "win8": {
            "#import": [ "win7" ]
        },
        "win8-x86": {
            "#import": [ "win8", "win7-x86" ]
        },
        "win8-x64": {
            "#import": [ "win8", "win7-x64" ]
        },
        "win8-arm": {
            "#import": [ "win8" ]
        },

        "win81": {
            "#import": [ "win8" ]
        },
        "win81-x86": {
            "#import": [ "win81", "win8-x86" ]
        },
        "win81-x64": {
            "#import": [ "win81", "win8-x64" ]
        },
        "win81-arm": {
            "#import": [ "win81", "win8-arm" ]
        },

        "win10": {
            "#import": [ "win81" ]
        },
        "win10-x86": {
            "#import": [ "win10", "win81-x86" ]
        },
        "win10-x64": {
            "#import": [ "win10", "win81-x64" ]
        },
        "win10-arm": {
            "#import": [ "win10", "win81-arm" ]
        },


        "aot": {
            "#import": [ "any" ]
        },

        "win-aot": {
            "#import": [ "win", "aot" ]
        },
        "win-x86-aot": {
            "#import": [ "win-aot", "win-x86" ]
        },
        "win-x64-aot": {
            "#import": [ "win-aot", "win-x64" ]
        },

        "win7-aot": {
            "#import": [ "win-aot", "win7" ]
        },
        "win7-x86-aot": {
            "#import": [ "win7-aot", "win7-x86" ]
        },
        "win7-x64-aot": {
            "#import": [ "win7-aot", "win7-x64" ]
        },

        "win8-aot": {
            "#import": [ "win8", "win7-aot" ]
        },
        "win8-x86-aot": {
            "#import": [ "win8-aot", "win8-x86", "win7-x86-aot" ]
        },
        "win8-x64-aot": {
            "#import": [ "win8-aot", "win8-x64", "win7-x64-aot" ]
        },
        "win8-arm-aot": {
            "#import": [ "win8-aot", "win8-arm" ]
        },

        "win81-aot": {
            "#import": [ "win81", "win8-aot" ]
        },
        "win81-x86-aot": {
            "#import": [ "win81-aot", "win81-x86", "win8-x86-aot" ]
        },
        "win81-x64-aot": {
            "#import": [ "win81-aot", "win81-x64", "win8-x64-aot" ]
        },
        "win81-arm-aot": {
            "#import": [ "win81-aot", "win81-arm", "win8-arm-aot" ]
        },

        "win10-aot": {
            "#import": [ "win10", "win81-aot" ]
        },
        "win10-x86-aot": {
            "#import": [ "win10-aot", "win10-x86", "win81-x86-aot" ]
        },
        "win10-x64-aot": {
            "#import": [ "win10-aot", "win10-x64", "win81-x64-aot" ]
        },
        "win10-arm-aot": {
            "#import": [ "win10-aot", "win10-arm", "win81-arm-aot" ]
        }
    }
 }
2
On

I took some time to review the docs and look at the code. Most of this answer comes from the code.

TargetFrameworkMoniker / tfm is constructed by using one of the constants from FrameworkIdentifiers in FrameworkConstants.cs . It is a framework identifier, plus a version concatenated on the end. Some examples include:

  • net451 (.NET 4.5.1)
  • dotnet (sort of a "current" tag for the latest .NET / portable class library)
  • uap10.0 (Universal Windows Application, for version 10, the latest as of this post)
  • native (for C/C++ code packaged using NuGet. Also take a look at CoApp if you intend to use this one)
  • MonoTouch
  • MonoAndroid
  • Xamarin.iOS

Plus others you can find in the code linked above.

For runtime identifiers, they are composed of an operating system identifier of some sort, plus an architecture. So, in JsonRuntimeFormatTests.cs you can find a few examples.

These include:

  • win8-x86
  • win10-x64
  • win10-arm
  • etc

This information has helped me structure a NuGet package that uses the runtimes folder, as I was struggling to know what the possible values were. I hope it helps someone else.