// NEXT APPROACH: Try writing the command to a batch file,
// then execute the batch file.
// The batch file DID execute properly,
// and the errors were displayed in the command box,
// but the output was not redirected when this was run from a separate process
// within .NET (C#).
// The error messages were indeed redirected to the given log file (cmpl_diag.txt)
// when the generated batch file was run directly from the command line.
// THIS is stuff that was tried before but did not work,
// including a pipe to another process that might handle the redirect.
//L_cmd = L_tsc_file_spec + $" --project C:/a01_temp/tsconfig.json";
//L_cmd = "cmd tsc" + $" --project C:/a01_temp/tsconfig.json";
//L_cmd = "tsc" + $" --project C:/a01_temp/tsconfig.json cmpl_diag.txt 2>&1";
//L_cmd = "tsc" + $" --project C:/a01_temp/tsconfig.json | more >cmpl_diag_02.txt";
//L_cmd = "tsc" + " --project C:\\a01_temp\\tsconfig.json | more >cmpl_diag_02.txt";
//L_cmd = "tsc" + " --project C:\\a01_temp\\tsconfig.json > cmpl_diag_02.txt 2>&1";
// THIS is the most-recent attempt.
L_cmd = "tsc" + $" --project C:/a01_temp/tsconfig.json > cmpl_diag_02.txt 2>&1";
// Creating the batch file.
L_bat_TS_file_spec = Path.Combine (L_file_path, "test.bat");
using (StreamWriter
L_SW = new StreamWriter (L_bat_TS_file_spec))
{
L_SW.Write (L_cmd);
}
psi = new ProcessStartInfo (L_bat_TS_file_spec);
// run without showing console windows
psi.CreateNoWindow = true;
psi.UseShellExecute = false;
psi.Verb = "runas";
// redirects the compiler error output, so we can read
// and display errors if any
psi.RedirectStandardOutput = true;
psi.RedirectStandardError = true;
L_tsc_process.StartInfo = psi;
L_tsc_process.Start();
// SHOULD read the error output
// ... but nothing was read.
var msg = L_tsc_process.StandardError.ReadToEnd();
// make sure it finished executing before proceeding
L_tsc_process.WaitForExit();
CONT'D ...