I'm new to C# (and development in general). I need to write a method in C# that will execute following via console: - install Newman; - execute postman Run.
I've created a method as below (I tried 2 options: ReadToEnd and WaitForExit), but it seems to stuck at each of these steps.
Any help how to make this to execute both commands in sequence (1st needs to finish before 2nd start) and exit after 2nd command executed fully?
Thanks in advance.
public string Runner ()
{
string readOutput = null;
var psiNpm = new ProcessStartInfo
{
FileName = "cmd",
RedirectStandardOutput = true,
RedirectStandardInput = true,
UseShellExecute = false
};
var pNpmRun = Process.Start(psiNpm);
pNpmRun.StandardInput.WriteLine($"npm install -g newman");
pNpmRun.WaitForExit();
//pNpmRun.StandardOutput.ReadToEnd();
pNpmRun.StandardInput.WriteLine($"newman run " +
$"\"C:\\Postman\\Test.postman.json\" " +
$"--folder \"TestSearch\" " +
$"--environment \"C:\\Postman\\postman_environment.json\" " +
$"--disable-unicode");
pNpmRun.StandardOutput.ReadToEnd();
pNpmRun.WaitForExit();
return readOutput = pNpmRun.StandardOutput.ReadLine();
}