Command HelperExecute With Output 方法
执行命令并获取输出(同步)。
Definition
命名空间: Suresking.Utility
程序集: Suresking.Utility (在 Suresking.Utility.dll 中) 版本:1.3.22+a27276bb8ffde055e69ff608e98aafba279e1e99
包含退出码、标准输出和标准错误的 CommandResult 对象。
程序集: Suresking.Utility (在 Suresking.Utility.dll 中) 版本:1.3.22+a27276bb8ffde055e69ff608e98aafba279e1e99
C#
public static CommandResult ExecuteWithOutput(
string command,
string? workingDirectory = null
)参数
返回值
CommandResult包含退出码、标准输出和标准错误的 CommandResult 对象。
备注
关于 dotnet format 的退出码:
- 0:成功,代码符合格式规范
- 1:错误,执行过程发生异常
- 2:使用 --verify-no-changes 时发现需要格式化的代码
实现说明:
使用异步方式并行读取标准输出与标准错误,避免因其中一个流缓冲区写满而导致的死锁。