2016-02-26 31 views
7

我有一個引用類庫項目的DNX控制檯應用程序。我正在嘗試發佈並將其安裝爲全局命令。將項目依賴項作爲全局命令運行Dnx控制檯應用程序

我在Windows 10操作系統上這樣做。 Projects Tree

控制檯項目Program.cs

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

控制檯項目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": {} 
    } 
} 

類庫:CommandLib文件: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; 
     } 
    } 
} 

類庫:project.json

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

我試圖安裝一個全局命令vm-test-job 要做到這一點,我

  1. 光盤放入src/Vert.Commands文件夾
  2. 發佈爲包
  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

當我嘗試運行我的命令vm-test-job我得到一個錯誤 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.

如何安裝的命令是在引用其他項目一個控制檯應用程序項目?

+0

歡迎來到StackOverflow。請你能指定操作系統(我猜這是Windows),你使用的框架版本。謝謝。 – Fab

+0

您是否指定了如下所述的依賴關係:http://docs.asp.net/en/latest/dnx/projects.html#adding-dependencies – Fab

+0

我確實指定了我的依賴關係,請在我的project.json文件中查看它們 –

回答

1

您是否嘗試過做一個...

dnu restore 

...安裝命令之前?我認爲在安裝之前,dnvm需要重建/重新包裝你的依賴關係。

看看這個鏈接,它試圖達到你所做的同樣的事情。 http://blogs.msdn.com/b/sujitdmello/archive/2015/04/23/step-by-step-installation-instructions-for-getting-dnx-on-your-laptop.aspx

+0

我曾嘗試做過恢復以前。如果依賴軟件包不在那裏,它不會讓我發佈它。問題是,當我嘗試安裝全局命令時,dnx不知道在哪裏找到項目引用。 –

相關問題