首页 > 解决方案 > 在 MACOS 中将参数传递给“打开”命令

问题描述

我在 .NET Core 中有一个应用程序,我必须使用脚本运行它。首先,我认为我必须拥有虚拟 Windows 才能打开我的应用程序的几个实例。我有带有该命令的 bat 脚本:

start ./Host/bin/Release/netcoreapp3.1/win-x64/Host.exe "./CONFIG/host1.json"

现在我发现我可以使用命令创建 OSX 可执行文件:

dotnet publish -r osx-x64 -c Release 

所以现在我可以使用 Macos Terminal 启动应用程序了

open ./Host/bin/Release/netcoreapp3.1/osx-x64/Host --args "./CONFIG/host1.json"

但是我必须将参数传递给主应用程序,并且 open 命令不想通过我的字符串传递。

我试过open -a Terminal ...or ... --args './CONFIG/host1.json'

我的主机应用程序已打开,但 main 中的 args[0] 为空。

如何正确传递我的字符串参数?

标签: c#shell.net-coreexecutable

解决方案


推荐阅读