Lua向C#逻辑迁移 一期 #13

将整个插件代码上传
This commit is contained in:
2025-10-26 21:48:39 +08:00
parent 56994b3927
commit 648386cd73
785 changed files with 53683 additions and 2 deletions

View File

@ -0,0 +1,74 @@
using System.Collections;
using System.Diagnostics;
using System.Text;
namespace UnrealSharpBuildTool;
public class BuildToolProcess : Process
{
public BuildToolProcess(string? fileName = null)
{
if (fileName == null)
{
if (string.IsNullOrEmpty(Program.BuildToolOptions.DotNetPath))
{
fileName = "dotnet";
}
else
{
fileName = Program.BuildToolOptions.DotNetPath;
}
}
StartInfo.FileName = fileName;
StartInfo.CreateNoWindow = true;
StartInfo.ErrorDialog = false;
StartInfo.UseShellExecute = false;
StartInfo.RedirectStandardError = true;
StartInfo.RedirectStandardInput = true;
StartInfo.RedirectStandardOutput = true;
EnableRaisingEvents = true;
}
public bool StartBuildToolProcess()
{
StringBuilder output = new StringBuilder();
OutputDataReceived += (sender, e) =>
{
if (e.Data != null)
{
output.AppendLine(e.Data);
}
};
ErrorDataReceived += (sender, e) =>
{
if (e.Data != null)
{
output.AppendLine(e.Data);
}
};
if (!Start())
{
throw new Exception("Failed to start process");
}
BeginErrorReadLine();
BeginOutputReadLine();
WaitForExit();
if (ExitCode != 0)
{
string errorMessage = output.ToString();
if (string.IsNullOrEmpty(errorMessage))
{
errorMessage = "BuildTool process exited with non-zero exit code, but no output was captured.";
}
throw new Exception($"BuildTool process failed with exit code {ExitCode}:\n{errorMessage}");
}
return true;
}
}