Blank Console Error on Empty Project with a Single C# Script
Problem
After updating Unity Hub and loading any project with C# scripts in it, I noticed that there were blank compiler errors that wouldn't go away, preventing the project from running or any of its scripts from being properly included.
Here's a screenshot of the project right after adding the script:
Steps To Reproduce
Open new Empty 3D Project
Add new C# script
That's it. A blank error will now appear in the console log and will not go away until you delete the C# Script.
Investigation/Error Output
Double clicking on the blank Console Error does nothing.
I took a look at the Editor Log file (in the upper right tab of the Console -> Open Editor Log) and found the following error at the bottom of Editor.log:
-----CompilerOutput:-stdout--exitcode: 9009--compilationhadfailure: True--outfile: Temp/Assembly-CSharp.dll
-----CompilerOutput:-stderr----------
'"C:\Program Files\Unity\Hub\Editor\2019.2.14f1\Editor\Data\Tools\RoslynScripts\..\..\Tools\Roslyn\csc"' is not recognized as an internal or external command,
operable program or batch file.
-----EndCompilerOutput---------------
- Finished compile Library/ScriptAssemblies/Assembly-CSharp.dll
View the full contents of Editor.log Here
I ran the program that the error supposedly said was not recognized ("C:\Program Files\Unity\Hub\Editor\2019.2.14f1\Editor\Data\Tools\RoslynScripts\..\..\Tools\Roslyn\csc") in a Windows Command prompt, and it seems like this command IS in fact valid:
Attempts to Fix
I tried uninstalling Unity and Visual Studio, removing all files I could find in the system that referenced Unity (I may have missed a few since Unity Hub somehow automatically logged me in after I reinstalled it), and rebooting my PC.
I also tried an older version of Unity, making a new project Unity Version 2019.2.13f1, a version that has worked on my PC before, but the same exact problem occured.
None of these attempts worked.
Unity Versions and OS
OS: Windows 10
Unity Version: 2019.2.14f1
Unity Hub Version: 2.2.0
Did you take a look at this question?
https://answers.unity.com/questions/1584147/every-time-i-start-a-new-project-appears-4-errors.html
Yeah tried that, didn't work. Switching runtime version/API Comparability Level had no impact. Thanks for forwarding that though!
Answer by adrisj7 · Nov 29, 2019 at 12:58 AM
I fixed it! Albeit in a non conventional way. Not sure why this worked, but I think this fix can be applied to other problems found when getting blank errors.
Here's exactly what I did:
(You should probably close the Unity Editor before doing this)
Go to "C:\Program Files\Unity\Hub\Editor\2019.2.14f1\Editor\Data\Tools\RoslynScripts"
Edit "unity_csc.bat"
Replace the line that says "%APPLICATION_CONTENTS%\Tools\Roslyn\csc" /shared % with the following: "C:\Program Files\Unity\Hub\Editor\2019.2.14f1\Editor\Data\Tools\Roslyn\csc.exe" /shared %
Reopen the same project in Unity and it should work.
I think if you just add an ".exe" to the end of the csc directory it should also work, but I also converted it into a full path anyways.
No clue why it worked, since you should be able to run executable commands without the ".exe" extension but I don't know much about Batch so maybe the bat file itself has something to do with it.
Can you paste your entire unity_csc.bat file? I am unable to fix it but at least now i see something ins$$anonymous$$d of a blank error Pls send a full empty project since my PC wont compile any version of Unity i use. and show blank errors in all unity versions..not even sure why.
Got the exactly same error that you, dunno how to fix it.
I got the exact same error when I wrote the path myself. I was able to fix just by using the default path, but adding the '.exe' extension. Just like @Sys_guru pointed out in a comment below.
"%APPLICATION_CONTENTS%\Tools\Roslyn\csc.exe" /shared %*
Thanks a lot for the solution, @adrisj7! I was going mad trying to understand what was going on. I tried reinstalling Unity and reinstalling Rider, but never thought to check Unity Hub!
Answer by AmitSuri · Nov 29, 2019 at 04:38 AM
Update to the accepted answer: Fix: Go to C:\Program Files\Unity\Hub\Editor\2019.2.14f1\Editor\Data\Tools\RoslynScripts folder Open the batch file in notepad and paste the following:
@ECHO OFF
set APPLICATION_CONTENTS=%~dp0..\..
echo host set to %APPLICATION_CONTENTS%
"C:\Program Files\Unity\Hub\Editor\2019.2.14f1\Editor\Data\Tools\Roslyn\csc.exe" /shared %*
exit /b %ERRORLEVEL%
Note the * at the end that is what was missing
[Update: the .exe was missing not the *]
I followed this edited fix and it worked. Thank you and @adrisj7 for the answer!
The question now is why this issue occurred in these projects? It happened see$$anonymous$$gly randomly on my end, and effectively broke my entire project. I am unsure of what csc even does, let alone why the path to it was broken.
I've tried ur approach for Unity 2019.17f1, but id didn't work for me. Any Idea? I couldn't find the mistake.
This doesn’t work for 2020.3.8 Any other other suggestions. I can’t find anything recent.
Answer by Sys_Guru · Nov 29, 2019 at 02:39 PM
Thanks for sharing the solution @adrisj7, I spent ages trying to figure this out.
Just adding ".exe" does work.
"%APPLICATION_CONTENTS%\Tools\Roslyn\csc.exe" /shared %*
Note that if you have multiple Unity versions, the fix has to be applied to each one.
Answer by BlackFuse · Sep 22, 2020 at 07:41 PM
Happend on 2018 4.0 with Win7, solved after installing Windows7 patch KB4457144, if anyone could not find folder "RoslynScripts" (mentioned in best answer), try this.
Answer by GameSurf · Feb 19, 2020 at 11:10 PM
Hi ! I changed SSD drive and I installed win10. I'm using my project with 2019.1.7f1.After a working while, 4 blank errors appeared. When i use my project with old drive, there is no blank errors! When i updated to 2019.2.21f1 errors decreased to 2 errors. I have been trying to solve this for days but couldnt get rid of this. I followed suggestions @adrisj7 but none of them work. I think the problem is about Win 10 (Microsoft Windows [Version 10.0.18363.657] ) Any suggestions?