0
votes

I am porting a ASP.NET Core DNX command line tool from RC1 to RC2 with dotnet. It uses the full framework 4.5.1. I have stripped it down to a very simple project. My suspicion is that I am missing something basic, but I can't seem to find parallel examples. Apologies in advance if this is a simple fix.

Steps to reproduce

Here is my project.json file.

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

Here is my program.cs file.

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;
        }
    }
}

I am creating a NuGet package and referencing that from another project as a tool.

Expected behavior

run dotnet hello Prints Hello World in red and then Test in red.

This works perfectly without the line to print Test.

Actual behavior

The following exception is shown. Hello World is not printed.

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)

At this point I get an error dialog to prompt for debugging.

I have tried this with a number of other assemblies with the same results.

I posted this as an issue on dotnet/cli in GitHub, but haven't received a response. https://github.com/dotnet/cli/issues/3274

Environment data

.NET Command Line Tools (1.0.0-preview1-002702)

Product Information: Version: 1.0.0-preview1-002702 Commit Sha: 6cde21225e

Runtime Environment: OS Name: Windows OS Version: 10.0.10586 OS Platform: Windows RID: win10-x64

1
Can you close this. I think you received a valid answer from the dotnet/cli team in your ticket?Thomas

1 Answers

0
votes

While it wasn't the answer I was looking for, it was addressed at https://github.com/dotnet/cli/issues/3274

The bottom line is that the .NET CLI team wants all tools to be cross platform, which I understand. It just poses some issues while the cross platform framework doesn't have all the features of the full framework.