Search Issue Tracker

By Design

Votes

2

Found in

2018.3.0a1

2018.3.0f2

2019.1.0a1

2019.2.0a1

Issue ID

1114064

Regression

No

[Roslyn] VBCSCompiler.exe remains running after Unity build has finished when building Unity Player in batch mode

Scripting

-

How to reproduce:
1. Create a new Unity project
2. Open PowerShell window
3. Run this command: "('- path to the Editor -\Unity.exe -projectPath "- path to the project -" -batchMode -quit -buildWindows64Player $pwd/Build/MyProject.exe -NoNewWindow -Wait -PassThru).ExitCode"
4. Wait for the build to finish
5. Open the Task Manager
6. Notice that the VBCSCompiler.exe is still running

Expected: VBCSCompiler.exe is shut down after the build finishes
Actual: VBCSCompiler.exe keeps running after the build finished until it times out

Reproducible with: 2018.3.13f1, 2019.1.0f2, 2019.2.0a11

Note: Roslyn Compiler was introduced in Unity 2018.3

  1. Resolution Note:

    The C# compiler runs in server mode and may outlive the lifetime of the Unity Editor.

Comments (8)

  1. EirikWahl

    Nov 05, 2021 07:32

    Workaround for CI servers: Before starting the Unity build (Unity.exe -batchmode etc), start VBCSCompiler.exe in a separate process. Then the CI build will correctly detect Unity.exe finishing, because the hanging VBCSCompiler.exe will be in another OS process.

  2. AstroCool

    Jul 13, 2020 13:06

    2019.2.21f still present.

  3. j_hansen

    Aug 06, 2019 07:25

    As others have said, the compiler not getting stopped causes a mess on CI machines.

  4. Newtopian

    Jul 25, 2019 20:37

    dotnet core team were faced with a similar issue and they introduced a command to close the build tools cleanly.

    refer to https://github.com/dotnet/cli/issues/8185 for more details.

    Since you are using Roselyn as well I would think that there should be a programmatic way to achieve the same result. Now, this behaviour is indeed by design so perhaps only activate this shutdown mechanics when running in batch mode, or perhaps though a specific command line argument.

    This may not be much of an issue when running Unity as a content creator or a programmer but it really wreak havoc on a CI system. In some cases it would cause the build to hang indefinitely at the very least it prevents the environment to be properly cleaned and propagated meaning that each job will no longer be in isolation but will have hidden dependencies on previous jobs that ran on the build node.

  5. neos-mlp

    Jul 10, 2019 07:47

    It's scary that Unity declares it as "by Design". This is a shitty design to be accurate. If I run in batch mode (for example on a CI server) I want to know when Unity is finished. Why the hell do you think this is a good design? Kill the fcking compiler when you're finished.

    The only way to get around this manually is to check every x seconds how many sub processes my script has spawned and check whether Unity.exe is one of them. If not, kill VBCSCompiler.
    Sad solution but thanks to Unity we have to do this.

  6. calebbbarton

    Jun 17, 2019 12:31

    So this is annoying, as our companies current setup has a batch file open unity in command mode with no GUI, do some asset bundle building in unity, then uploads the files afterwards. However, because the VBCSCompiler doesn't close, the batch command file thinks unity is still open, and wont execute the upload unless force killed.

    Any ideas as to how to get around that?

  7. skullthug

    May 31, 2019 18:35

    I'm having an issue on one of my machines where VBCSCompiler.exe is still running and out of control to the point of locking up the system. Unsure if it's related to this, but this is the closest thing I've been able to Google about it.

  8. scottrmathews

    May 17, 2019 23:15

    This is also happening in 2018.4.0.

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.