Add automatic building of nethost for consoles

This commit is contained in:
Wojtek Figat
2024-01-15 17:30:45 +01:00
parent ec6fb459bb
commit 3bdc70a4c6
2 changed files with 122 additions and 90 deletions

View File

@@ -320,6 +320,11 @@ namespace Flax.Build
/// </summary>
ConsoleLogOutput = 1 << 7,
/// <summary>
/// Enables <see cref="ProcessStartInfo.UseShellExecute"/> to run process via Shell instead of standard process startup.
/// </summary>
Shell = 1 << 8,
/// <summary>
/// The default options.
/// </summary>
@@ -398,11 +403,12 @@ namespace Flax.Build
}
bool redirectStdOut = (options & RunOptions.NoStdOutRedirect) != RunOptions.NoStdOutRedirect;
bool shell = options.HasFlag(RunOptions.Shell);
Process proc = new Process();
proc.StartInfo.FileName = app;
proc.StartInfo.Arguments = commandLine != null ? commandLine : "";
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.UseShellExecute = shell;
proc.StartInfo.RedirectStandardInput = input != null;
proc.StartInfo.CreateNoWindow = true;
@@ -411,7 +417,7 @@ namespace Flax.Build
proc.StartInfo.WorkingDirectory = workspace;
}
if (redirectStdOut)
if (redirectStdOut && !shell)
{
proc.StartInfo.RedirectStandardOutput = true;
proc.StartInfo.RedirectStandardError = true;
@@ -427,16 +433,24 @@ namespace Flax.Build
}
}
if (envVars != null)
if (envVars != null && !shell)
{
foreach (var env in envVars)
{
if (env.Key == "PATH")
{
// Append to path
proc.StartInfo.EnvironmentVariables[env.Key] = env.Value + ';' + proc.StartInfo.EnvironmentVariables[env.Key];
}
else if (env.Value == null)
{
// Remove variable
if (proc.StartInfo.EnvironmentVariables.ContainsKey(env.Key))
proc.StartInfo.EnvironmentVariables.Remove(env.Key);
}
else
{
// Set variable
proc.StartInfo.EnvironmentVariables[env.Key] = env.Value;
}
}