COMPILES TO EXE

This commit is contained in:
Pasha Bibko
2025-05-03 21:48:16 +01:00
parent 3386272f2a
commit 8d9c850206
8 changed files with 92 additions and 184 deletions

View File

@@ -0,0 +1,47 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LX_Build
{
internal class CommandProcess
{
private readonly string m_ErrorMessage;
private readonly int m_ExitCode;
public int ExitCode() => m_ExitCode;
public string Error() => m_ErrorMessage;
public CommandProcess(string command)
{
// Creates a process to run the command //
ProcessStartInfo info = new()
{
FileName = "cmd.exe",
Arguments = $"/c {command}",
RedirectStandardError = true,
RedirectStandardOutput = true,
UseShellExecute = false,
CreateNoWindow = true,
};
// Starts the process //
using Process process = Process.Start(info);
// Reads the streams of the output //
string output = process.StandardOutput.ReadToEnd();
string error = process.StandardError.ReadToEnd();
// Waits for the process to exit //
process.WaitForExit();
// Assigns output of the error for external access //
m_ExitCode = process.ExitCode;
m_ErrorMessage = error;
}
}
}