Is there a way to write to the stdout from a standalone?
I have a console application that fires up a standalone in headless mode but I haven’t been able to find a way to write to the stdout.
Here’s the code that launches the standalone:
var startInfo = new ProcessStartInfo
{
FileName = Directory.GetCurrentDirectory() + "\\Server\\server.exe",
Arguments = "-batchmode",
RedirectStandardOutput = true,
UseShellExecute = false,
};
_process = new Process
{
StartInfo = startInfo
};
_process.OutputDataReceived += Received;
_process.Start();
I found the solution that works for me (in Linux for sure) - just pass -logFile /dev/stdout to your executable file. Not sure that such trick will work in Windows
I wrote a small tool in C# to do exactly this. You have to set the UNITY environment variable to your Unity executable (“C:\Program Files\Unity\Editor\Unity.exe” in most cases).
Then execute UnityCli.exe where you could use Unity.exe for example:
UnityCli.exe -batchmode -nographics -projectPath "%CD%\Unity" -executeMethod CI.BuildAll -quit -logFile build_unity.txt
The tool will automatically detect the “-logFile” parameter and redirect that output to the console while it happens so it’s great for CI!