admin 管理员组文章数量: 1086019
I am trying to manipulate my swagger doc. I need to run redoc split
to separate the main swagger.
During start.cs I am getting the swagger doc and saving it to the file system. That works as expected. Then in my split method, I get the swagger doc and run it through redoc split
and nothing happens, no error and no messages. I put breakpoints on the first line, inside the Try block and when I step, it exits so I think an error is getting swallowed somewhere.
I can run this from a command window just fine.
public static void RunSplitCommand()
{
string output = string.Empty;
string error = string.Empty;
var args = "redocly split \"../bin/swagger/Swagger.json\" --outDir= \"../bin/swagger\"";
using (var process = new System.Diagnostics.Process())
{
process.StartInfo = new System.Diagnostics.ProcessStartInfo();
process.StartInfo.WorkingDirectory = Directory.GetCurrentDirectory();
process.StartInfo.FileName = "cmd.exe";
process.StartInfo.Arguments = args;
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;
try
{
process.Start();
process.WaitForExit();
if (process.StandardOutput.ReadToEnd() != string.Empty)
output = process.StandardOutput.ReadToEnd();
else if (process.StandardError.ReadToEnd() != string.Empty)
output = process.StandardError.ReadToEnd();
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
}
string.Concat(output, "\n");
}
本文标签: How do I run a CMD from CStack Overflow
版权声明:本文标题:How do I run a CMD from C#? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://roclinux.cn/p/1744023779a2520271.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论