简体   繁体   English

如何从 .net 核心项目运行“do.net myDll.dll”?

[英]How to run "dotnet myDll.dll" from a .net core project?

I have a .net core project on mac/linux, which I can run from the terminal using我在 mac/linux 上有一个 .net 核心项目,我可以使用它从终端运行

         dotnet myDll.dll

I want to run this from my c# project code - so start up the webapp and then run ui tests against it.我想从我的 c# 项目代码运行它 - 所以启动 webapp 然后对其运行 ui 测试。

I have tried我试过了

        var path = "path-to-my-dll/myDll.dll");

        var processStartInfo = new ProcessStartInfo(path, "")
        {
            WorkingDirectory = Path.GetDirectoryName(path)
        };

        var process = Process.Start(processStartInfo);

However this just runs the terminal equivalent of然而,这只是运行终端相当于

        ./myDll.dll

How do I call the do.net command?如何调用 do.net 命令?

Thanks to huysentruitw and Execute do.net command with Process in C#感谢 huysentruitw 和Execute do.net command with Process in C#

var processStartInfo = new ProcessStartInfo(expected, "")
        {
            FileName = "dotnet",
            Arguments = "myDll.dll",
            WorkingDirectory = Path.GetDirectoryName(path)
        };

You should be able to pass do.net as a fileName and myDll.dll as the startup argument to the ProcessStartInfo constructor , like this:您应该能够将do.net作为fileName名和myDll.dll作为启动参数传递给ProcessStartInfo构造函数,如下所示:

var processStartInfo = new ProcessStartInfo("dotnet", "myDll.dll")
{
    WorkingDirectory = Path.GetDirectoryName(path),
};

var process = Process.Start(processStartInfo);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用python3和pythonnet在mydll.dll中使用断点 - how to use breakpoint in mydll.dll using python3 and pythonnet 无法加载DLL'mydll.dll':找不到指定的模块 - Unable to load DLL ' mydll.dll': The specified module could not be found 调试无法加载DLL“ MyDll.dll”:找不到指定的模块。 (来自HRESULT的异常:0x8007007E) - Debugging Unable to load DLL 'MyDll.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E) 运行命令“ dotnet project.dll”时,如何在.net core 1.1中获取正确的应用程序路径? - How to get the right application path in .net core 1.1 when run command “dotnet project.dll”? 如何运行.Net Core dll? - How to run a .Net Core dll? 使用 dotnet run 时如何调试 .NET 核心控制台应用程序 - How to Debug a .NET Core Console App When Using dotnet run 从另一个 .NET Core 应用程序运行 .NET Core dll - Run .NET Core dll from another .NET Core app 如何配置Visual Studio代码以从Windows的Linux子系统(WSL)运行/调试.NET(dotnet)Core? - How can I configure Visual Studio Code to run/debug .NET (dotnet) Core from the Windows Subsystem for Linux (WSL)? 如何从 ASP.NET Core MVC 项目的 dll 获取类型 - How to get types from dll of an ASP.NET Core MVC project 如何在 devops 项目中实现 dotnet core 3.0? - How to implement dotnet core 3.0 in devops project?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM