7

I have a DNX console application that references a class library project. I am trying to publish this and install it as a global command.

I am doing this on Windows 10 OS. Projects Tree

Console Project Program.cs

namespace Vert.Commands
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var test = new ConsoleWriter();
            test.Talk("Test", ConsoleColor.Cyan);
        }
    }
}

Console Project project.json

{
  "version": "1.0.0-*",
  "description": "Test App",
  "authors": [ "vrybak" ],
  "tags": [ "" ],
  "projectUrl": "",
  "licenseUrl": "",
  "compilationOptions": {
    "emitEntryPoint": true
  },
  "dependencies": {
    "CommandLib": "1.0.0-*"
  },
  "commands": {
    "vm-test-job": "Vert.Commands"
  },
  "frameworks": {
    "dnx451": {}
  }
}

Class Library: CommandLib file: ConsoleWriter

namespace CommandLib
{
    public class ConsoleWriter
    {
        public void Talk(string message, ConsoleColor color)
        {
            var currentColor = Console.ForegroundColor;
            Console.ForegroundColor = color;
            Console.WriteLine(message);
            Console.ForegroundColor = currentColor;
        }
    }
}

Class Library: project.json

{
  "version": "1.0.0-*",
  "description": "CommandLib Class Library",
  "authors": [ "vrybak" ],
  "tags": [ "" ],
  "projectUrl": "",
  "licenseUrl": "",
  "frameworks": {
    "dnx451": { }
  }
}

I am trying to install a global command vm-test-job To do this I

  1. cd into the src/Vert.Commands folder
  2. publish it as a package
  3. dnu publish --no-source -o artifacts\publish
  4. cd \artifacts\publish\approot
  5. dnu commands install .\packages\Vert.Commands\Vert.Commands.1.0.0.nupkg

When I try to run my command vm-test-job I get an error System.IO.FileNotFoundException: Could not load file or assembly 'CommandLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

How do I install a command that is in a console app project that references other projects?

Vadim Rybak
  • 1,677
  • 20
  • 25
  • Welcome to StackOverflow. Please could you specify OS (I guess it's Windows), framework version you use. Thank you. – Fab Mar 02 '16 at 07:18
  • Did you specify dependencies as specified here : http://docs.asp.net/en/latest/dnx/projects.html#adding-dependencies – Fab Mar 02 '16 at 07:21
  • I did specify my dependencies, take a look at them in my project.json file – Vadim Rybak Mar 02 '16 at 12:26

1 Answers1

1

Have you tried doing a...

dnu restore

...before installing the command ? I think dnvm needs to rebuild/repack your dependencies prior to install.

Take a look at this link, which tries to achieve the same thing as you do I assume. http://blogs.msdn.com/b/sujitdmello/archive/2015/04/23/step-by-step-installation-instructions-for-getting-dnx-on-your-laptop.aspx

OgaFuuu
  • 33
  • 8
  • I have tried doing the restore before as well. It would not let me publish it if the dependent packages were not there. The problem is that when I try to install a global command, dnx doesn't know where find the project references. – Vadim Rybak Mar 07 '16 at 18:26