我有一個引用類庫項目的DNX控制檯應用程序。我正在嘗試發佈並將其安裝爲全局命令。將項目依賴項作爲全局命令運行Dnx控制檯應用程序
控制檯項目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
要做到這一點,我
- 光盤放入
src/Vert.Commands
文件夾 - 發佈爲包
dnu publish --no-source -o artifacts\publish
- cd
\artifacts\publish\approot
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.
如何安裝的命令是在引用其他項目一個控制檯應用程序項目?
歡迎來到StackOverflow。請你能指定操作系統(我猜這是Windows),你使用的框架版本。謝謝。 – Fab
您是否指定了如下所述的依賴關係:http://docs.asp.net/en/latest/dnx/projects.html#adding-dependencies – Fab
我確實指定了我的依賴關係,請在我的project.json文件中查看它們 –