我有一个引用类库项目的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文件中查看它们 –