【问题标题】:Which version of coreclr?哪个版本的coreclr?
【发布时间】:2016-04-27 12:15:05
【问题描述】:

在 .NET CLI 中,我可以使用开关 --version 来获取 CLI 的版本。有没有类似的方法来获取coreclr的版本?

【问题讨论】:

    标签: .net asp.net-core coreclr


    【解决方案1】:

    没有更多dnvm

    coreclr 的版本在您的project.json 文件中确定。

    安装 dotnet cli 时还有一个共享运行时。您可以在 dotnet cli 文件夹中找到它。

    如果您的应用程序没有在 project.json 中指定任何运行时,那么您的应用程序是可移植的,并且将使用共享运行时运行。您可以指定多个运行时,并且将为所有这些运行时分别编译您的应用程序二进制文件。

    更新

    添加指向 .NET Platform Standard 文档的链接,该文档描述了在 .NET 中设计 API 的新方法

    链接到 David Fowl 的 GitHub repository 描述 .NET Platform Standard

    这是一个指定运行时的示例

    {
      "version": "1.0.0-*",
      "compilationOptions": {
        "warningsAsErrors": true,
        "preserveCompilationContext": true,
        "emitEntryPoint": true
      },
      "dependencies": {
           ...
      },
      "frameworks": {
        "net451": {
          "dependencies": {
            ....
          }
        },
        "netcoreapp1.0": {
          "imports": [
            "dnxcore50",
            "portable-net45+win8"
          ],
          "dependencies": {
            "NETStandard.Library": "1.5.0-rc2-24018",
            "Microsoft.DotNet.ProjectModel": "1.0.0-rc2-002416"
          }
        }
      },
      "content": [
        "config.json"
      ],
      "runtimes": {
        "win7-x64": {},
        "win7-x86": {},
        "osx.10.11-x64": {},
        "ubuntu.14.04-x64": {},
        "centos.7-x64": {},
        "rhel.7.2-x64": {},
        "debian.8.2-x64": {}
      }
    }
    

    【讨论】:

    • @ShaunLuttin 没有更多通过dnvm 维护的本地安装运行时。您的所有运行时都使用 project.json 在您的应用程序中进行管理
    【解决方案2】:

    coreclr 的版本在我们应用程序的 project.json 中。 dnvm list -detailed(来自之前的工具链)向我们展示了与 dotnet 工具链完全无关的运行时信息。

    > dnvm list -detailed
    Active Version         Runtime Architect OperatingSystem Alias   Location
    ------ -------         ------- --------- --------------- -----   --------
           1.0.0-rc2-16595 coreclr x64       win                     C:\Users\me\.dnx\runtimes 
      *    1.0.0-rc2-20221 clr     x86       win             default C:\Users\me\.dnx\runtimes
    

    我们可以找到等价的dotnet相关信息:

    • 版本和运行时位于 project.json 的 frameworks 部分(例如 netcoreapp1.0、net451)。
    • 架构和操作系统位于 project.json 的 runtimes 部分(例如 win7-x64)。
    • Location 是还原后的 NuGet 全局包文件夹 (nuget locals all -list) 和构建后项目的 bin
    • Alias 和 Active 已过时。

    "There's no dnvm replacement" 用于 .NET CLI,并且没有“获取 coreclr 版本”的命令。这是因为运行时现在已在我们的 project.json 中完全指定,并使用 dotnet restore 命令安装。

    使用dnu/dnx/dnvm 工具链,我们独立于我们的应用程序及其依赖项安装了运行时。

    1. 我们使用dnvm install|upgrade|use 来下载和使用运行时; dnvm 没有咨询 project.json。
    2. 我们使用dnu restore 来下载应用程序特定的依赖项; dnu 确实咨询过 project.json。

    使用dotnet 工具链,restore 操作结合了这两个步骤。它会查阅我们的 project.json 并下载运行时和依赖项。

    dnvm 不与dotnet 工具链交互。事实上,我们可以删除~/.dnx目录,dotnet将构建我们的项目。

    【讨论】:

    • 我的印象是 dnvm 已被弃用,而 dotnet 取代了整个 dnu、dnx、dnvm 工具链,但我想它并不是真的在这种情况下很重要,至少在它消失之前不会。
    • @Marcus “没有 dnvm 替代品。” hanselman.com/blog/AnUpdateOnASPNETCore10RC2.aspx
    【解决方案3】:

    现有的答案可能包含所有信息,但这部分被遗留信息所掩盖,所以让我尝试从 .NET Core v2.0 beta 开始的实用总结。。支持>

    • dotnet --version[1] 报告, 有一个全球有效的 SDK 版本支持> ,

    • no 全局有效的runtime (CoreCLR) 版本 - 运行时是并行安装的,并且 每个项目通过其*.csproj 文件确定它的目标运行时

    列出所有已安装 CoreCLR 版本

    • bash

      • ls -1 "$(dirname "$(which dotnet)")/shared/Microsoft.NETCore.App"
    • PowerShell Core(Windows 和 Unix)中:

      • (Get-ChildItem "$((Get-Command -Type Application dotnet).source)/../shared/Microsoft.NETCore.app").Name

    检查给定项目的目标CoreCLR:(运行项目根文件夹中的命令):

    • bash

      • awk -F '</?RuntimeFrameworkVersion>' 'NF>1 {print $2}' *.csproj
    • PowerShell Core(Windows 和 Unix)中:

      • ([xml] (Get-Content -Raw *.csproj)).Project.PropertyGroup.RuntimeFrameworkVersion

    有关包含此功能及更多功能的 PowerShell Core 脚本,请参阅我的 this Gist


    [1] (可选)在每个项目的基础上,您可以通过在项目文件夹中放置 global.json 文件来覆盖全局有效的 SDK 版本 - 请参阅 the docs
    另请注意,仅运行dotnet不带参数或运行dotnet --version没有安装SDK将显示反映共享主机的文本(“ driver") 版本 - 这种晦涩难懂的行为正在 GitHub here 上进行讨论。

    【讨论】:

      猜你喜欢
      • 2016-11-03
      • 1970-01-01
      • 2021-02-25
      • 2013-11-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-06-21
      相关资源
      最近更新 更多