简体   繁体   English

NuGet - RID和TFM示例

[英]NuGet - RID and TFM Examples

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. 我一直在GitHub上查看NuGet3的代码,我在https://github.com/NuGet/NuGet3/blob/a5bc907d36ddaa8d4fa6c499e50d7ebf8993ed39/src/NuGet.Client/ManagedCodeConventions.cs中看到了与预期文件夹结构相关的几个文件夹模式一个NuGet包。 However, I'm having a hard time finding any examples of these - specifically the rid and tfm values. 但是,我很难找到这些的例子 - 特别是rid和tfm值。

How can I know all the possible values for rid and tfm? 我如何知道rid和tfm的所有可能值? I know they mean Runtime Identifier and Target Framework Moniker, but I don't really know what to do with that. 我知道他们的意思是运行时标识符和目标框架Moniker,但我真的不知道如何处理它。

The documentation that I've seen never seems to deal with the topic directly or exhaustively. 我见过的文档似乎从未直接或详尽地处理该主题。

The target frameworks are currently hard coded within the NuGet source code. 目标框架目前在NuGet源代码中进行了硬编码。 Whilst some of the target frameworks are documented on the NuGet website there are many which are not documented there. 虽然NuGet网站上记录了一些目标框架,但有许多目标框架没有在那里记录。 So as Jeff R already mentioned the best way to find the target frameworks is currently to look at the NuGet source code. 因此,当Jeff R已经提到找到目标框架的最佳方法时,目前要查看NuGet源代码。

NuGet also has short identifiers for some of these frameworks (eg wp = WindowsPhone). NuGet还有一些这些框架的短标识符 (例如wp = WindowsPhone)。

The runtime identifiers defined by Microsoft are available in the Microsoft.NETCore.Platforms NuGet package . Microsoft定义的运行时标识符可在Microsoft.NETCore.Platforms NuGet包中找到 Inside this NuGet package is a runtime.json file with the runtime identifiers: 在这个NuGet包中是一个带有运行时标识符的runtime.json文件:

{
    "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" ]
        }
    }
 }

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 . TargetFrameworkMoniker / tfm是使用FrameworkConstants.cs中的FrameworkIdentifiers中的一个常量构造的。 It is a framework identifier, plus a version concatenated on the end. 它是一个框架标识符,加上最后连接的版本。 Some examples include: 一些例子包括:

  • net451 (.NET 4.5.1) net451(.NET 4.5.1)
  • dotnet (sort of a "current" tag for the latest .NET / portable class library) dotnet(最新.NET /便携式类库的“当前”标记)
  • uap10.0 (Universal Windows Application, for version 10, the latest as of this post) uap10.0(通用Windows应用程序,版本10,最新版本)
  • native (for C/C++ code packaged using NuGet. Also take a look at CoApp if you intend to use this one) native(用于使用NuGet打包的C / C ++代码。如果您打算使用这个,请查看CoApp)
  • MonoTouch MonoTouch的
  • MonoAndroid MonoAndroid
  • Xamarin.iOS 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. 因此,在JsonRuntimeFormatTests.cs中,您可以找到一些示例。

These include: 这些包括:

  • win8-x86 win8的-86
  • win10-x64 win10-64
  • win10-arm win10臂
  • 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. 这些信息帮助我构建了一个使用runtimes文件夹的NuGet包,因为我很难知道可能的值是什么。 I hope it helps someone else. 我希望它可以帮助别人。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM