1

I'm calling cmd /C gradlew assembleRelease from C# code. I'm trying to display the gradle output log into the C# console (or file). This code is from a nuget package running in Unity.

Attempts so far:

cmd /C gradlew assembleRelease > gradleLog.txt
Log(File.ReadAllText("gradleLog.txt"))

I just get the C# stacktrace. Not the gradle log.

Tried this answer with the same result: https://stackoverflow.com/a/206347

Is it possible to get the whole gradle output to the console or a file in such a scenario? Let me know if you guys need more information. Thanks!

1 Answers1

0

I'm not sure how cradle works but calling it like the example from the link should work, if you read the output and the errors after the p.WaitForExit(); call.

Process p = new Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.Arguments = " assembleRelease";
p.StartInfo.FileName = "gradlew";
p.Start();
p.WaitForExit();
string output = p.StandardOutput.ReadToEnd();
string error = p.StandardError.ReadToEnd();

And maybe you should add some additional arguments for cradle:

p.StartInfo.Arguments = " -i -s assembleRelease";
geraphl
  • 305
  • 4
  • 10