【问题标题】:DotNet CLI tools fail using the full frameworkDotNet CLI 工具使用完整框架失败
【发布时间】:2016-10-01 00:21:16
【问题描述】:

我正在使用 dotnet 将 ASP.NET Core DNX 命令行工具从 RC1 移植到 RC2。它使用完整的框架 4.5.1。我已将其简化为一个非常简单的项目。我怀疑我缺少一些基本的东西,但我似乎找不到平行的例子。如果这是一个简单的解决方法,请提前道歉。

重现步骤

这是我的 project.json 文件。

{
  "version": "1.0.2-alpha001",
  "description": "Tools.Cli Class Library",
  "authors": [ "Test" ],
  "buildOptions": {
    "emitEntryPoint": true,
    "outputName": "dotnet-hello"
  },
  "dependencies": {
    "Microsoft.DotNet.Cli.Utils": "1.0.0-preview1-002702"
  },
  "frameworks": {
    "net451": { }
  }
}

这是我的 program.cs 文件。

using System;
namespace Tools.Cli
{
    public class Program
    {
        public static int Main(string[] args)
        {
            Console.WriteLine("\x1B[31m" + "Hello World" + "\x1B[39m");
            // The following line causes the error. Commenting out this line allows this to run.
            Console.WriteLine(Microsoft.DotNet.Cli.Utils.AnsiColorExtensions.Red("Test"));
            return 0;
        }
    }
}

我正在创建一个 NuGet 包并将其作为工具从另一个项目中引用。

预期行为

运行dotnet hello 以红色打印 Hello World,然后以红色打印 Test。

这在没有打印测试行的情况下完美运行。

实际行为

显示以下异常。未打印 Hello World。

dotnet hello
Unhandled Exception: System.IO.FileNotFoundException: 
    Could not load file or assembly 'Microsoft.DotNet.Cli.Utils, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' or one of its dependencies. 
    The system cannot find the file specified.
    at Tools.Cli.Program.Main(String[] args)

此时我收到一个错误对话框,提示进行调试。

我已经尝试过许多其他程序集,结果相同。

我将此作为问题发布在 GitHub 的 dotnet/cli 上,但尚未收到回复。 https://github.com/dotnet/cli/issues/3274

环境数据

.NET 命令行工具 (1.0.0-preview1-002702)

产品信息: 版本:1.0.0-preview1-002702 提交沙:6cde21225e

运行时环境: 操作系统名称:Windows 操作系统版本:10.0.10586 操作系统平台:Windows RID:win10-x64

【问题讨论】:

  • 你能关闭这个吗?我认为您在工单中收到了来自 dotnet/cli 团队的有效答复?

标签: command-line-interface .net-core dotnet-cli


【解决方案1】:

虽然这不是我想要的答案,但它的地址是 https://github.com/dotnet/cli/issues/3274

底线是 .NET CLI 团队希望所有工具都是跨平台的,我理解这一点。它只是提出了一些问题,而跨平台框架不具备完整框架的所有功能。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-03-10
    • 2019-08-21
    • 1970-01-01
    • 1970-01-01
    • 2016-11-09
    • 2021-06-06
    • 1970-01-01
    相关资源
    最近更新 更多