Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by Xarbrough · Oct 19, 2016 at 09:20 PM · c#buildpipelinecommand-line

Get Console or Debug.Log output from Unity command line batch mode and custom build process

I'm working on a small automated build process for my current project. I'm calling Unity in batch mode from within a WinForms C# application similar to this:

 "C:\Program Files\Unity\Editor\Unity.exe" -quit -batchmode -projectPath xxx -logFile xxx -executeMethod MyBuilder.MyBuildMethod -someMoreArgs

In Unity I have the MyBuilder.MyBuildMethod which performs my automated build. Unity has its own logFile, which I can add to by using Debug.Log().

The documentation says: "Note that in batch mode, Unity sends a minimal version of its log output to the console." How do I get this console output in my calling application?

I've tried to RedirectStandardOutput, but it only returns an empty string. I'd like to read Unity's "minimal output" and optionally my own by using Debug.Log or Console.WriteLine.

Here is my WinForms C# code for starting the build:

 Process p = new Process
 {
     StartInfo = new ProcessStartInfo
     {
         FileName = Settings.Default.UnityFilePath,
         Arguments = GetBuildArguments(),
         UseShellExecute = false,
         RedirectStandardOutput = true,
     }
 };
 p.Start();
 Console.WriteLine("Begin read output");
 Console.WriteLine(p.StandardOutput.ReadToEnd());
 Console.WriteLine("Done read output");
 p.WaitForExit();

Edit:

As of January 2017, Unity doesn't send standard output on Windows. I've read that it would work on Mac OSX, but not sure how adequately that performs. I have settled on the more hacky solution of adding a FileSystemWatcher to report on changes to the Unity log file and also reading every couple of seconds and log those lines from the file that are new. Only watching file changes also didn't work, because this would require that Unity would immediately write their statements into the file and mark the file as changed, but of course it only happens in certain chunks, which is why I also had to check every couple of seconds. The produced feedback was a little delayed, but good enough for me.

I am looking forward to improvements in this sector. Unity mentions a couple of features concerning build reporting on their roadmap and I hope this will include a public API for users or at least some better callbacks and data to query.

Comment
Add comment · Show 4
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Shawn-Halwes · Jan 24, 2017 at 03:46 AM 0
Share

@Xarbrough I see this is old and no one replied to you. Just curious if you found an answer for this. Thanks.

avatar image Xarbrough Shawn-Halwes · Jan 24, 2017 at 02:21 PM 0
Share

See my edit. ;)

avatar image Shawn-Halwes Xarbrough · Jan 24, 2017 at 03:08 PM 0
Share

@Xarbrough thanks for the update

Show more comments

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

227 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Making a bubble level (not a game but work tool) 1 Answer

ArgumentException: targetGroup must be valid 1 Answer

An OS design issue: File types associated with their appropriate programs 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges