Search Unity

  1. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  2. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  3. Want more efficiency in your development work? Sign up to receive weekly tech and creative know-how from Unity experts.
    Dismiss Notice
  4. Participate with students all over the world and build projects to teach people. Join now!
    Dismiss Notice
  5. Build games and experiences that can load instantly and without install. Explore the Project Tiny Preview today!
    Dismiss Notice
  6. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  7. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Unity Incremental C# Compiler - deprecated

Discussion in 'Entity Component System and C# Job system' started by Dom_Laflamme, Mar 28, 2018.

  1. Dom_Laflamme

    Dom_Laflamme

    Unity Technologies

    Joined:
    Sep 25, 2013
    Posts:
    26
    Deprecation Note:
    _____________________________________________________________


    Unity Incremental Compiler


    One solution we are working on to get us closer to our 500ms goal is a new compilation pipeline, which includes a new C# incremental compiler. Built using Microsoft's Roslyn open source compiler project, our new C# compiler is designed to dramatically accelerate iterating on your C# code as well as giving you access to the latest and greatest C# 7.2 features.


    Building our own compiler has several advantages. First, our compiler can cache all kinds of data from one compilation to the next, which means that code and references that didn't change won't get reparsed or reloaded (hence the name "incremental compiler"). Second, even though this compiler could be used to compile any dotNET code, it was written with a-priori knowledge about compiling Unity projects, which means we can do things (or skip things) other compilers cannot.


    Some Preliminary Numbers




    In the image above, you can see the effect the compiler cache has over the compilation time. Notice that the time to compile the first assembly is the same between the built-in Unity compiler and the incremental compiler (about 1.8 seconds). This is because being the first assembly we compile, no caching can occur. Subsequent compilations however benefit tremendously from caching.





    As you can see, the most interesting performance gains are achieved on subsequent “incremental” compilations, when iterating back and forth between code and Unity (when it typically hurts the most). The image above shows the effect of changing one file in an assembly which is referenced by many others. The assembly in question (Unity.Mathematics) is rebuilt, then all assemblies dependant on it are quickly re-emitted.

    That graph shows a couple of important things. First, it shows that the compiler is optimized for iterative changes where just a few files are changed at a time. Second, it shows that to squeeze the most performance out of the compiler, it is crucial to modularize your code using asmdef files. The compiler heavily relies on analyzing dependencies between assembly to recompile only the bare minimum. Chugging all your code in one big Assembly-CSharp.dll will only result in modest performance gains.

    Some disclaimer on the numbers

    The numbers you see are numbers we were able to measure in our lab and are subject to change quite a bit, as we add features and make additional changes. Also, the numbers you see are in milliseconds, but adding those numbers together does not equal the total time for recompilation and domain reloading (the time “felt” by the user). This is because even with the built-in compiler, some of these compilations occur in parallel. Furthermore, the new compiler does not impact the time it takes to do a “domain reload” (or enter-playmode).

    Other Cool Stuff

    Other cool stuff we get from writing our own compiler is support for C# 7.2, which gives you nifty ref returns, readonly and ref structs. We are also giving you the ability to write your own language rules and custom error messages. This is useful if you want to enforce coding conventions or generate compilation errors when, say, GetComponent<> is used in an Update method, or inside a for-loop, etc.

    Can I Help?

    If you'd like to give this new compiler a try, we are making the early alpha available today. See below for installation instructions. It is still early days for this technology and you might find problems - we'd love to get your feedback, good and bad :)

    Installation Instructions

    The incremental compiler comes as a package you can include in your project via the Package Manager manifest.

    1- Download and install Unity 2018.1 BETA 12

    The compiler might work with earlier 2018 Beta versions of Unity, but you will not be able to debug your code without B12.


    2- Add this to your manifest file

    Code (JavaScript):
    1. {
    2.     "dependencies": {
    3.         "com.unity.incrementalcompiler": "0.0.30"
    4.     },
    5.     "registry": "https://staging-packages.unity.com"
    6. }
    3- Set your scripting runtime to version 4.x in project's player settings
    The compiler client loaded by Unity needs this.

    4- Delete your project’s Library/ScriptAssemblies folder


    This will remove the last assemblies compiled built by the built-in compiler and will ensure the new compiler starts with a fresh, full recompilation.

    5- Configure the Compiler from the Preference window

    A new “Compiler” section is added to the Unity Preference window. You can control some compiler settings from there.

    Feedback

    And we’d love to hear what you think!
    Please feel free to post your questions and comments here.
     
    Last edited by a moderator: Dec 11, 2018 at 3:54 PM
  2. orb

    orb

    Joined:
    Nov 24, 2010
    Posts:
    2,950
    I'm sure many have been waiting for some Roslyn upgrades and especially the newest C# version. It's great to finally have access to it. I installed this in a fresh project just now, and nothing exploded. No wonder, as I haven't written any explosion scripts or made particle effects yet ;)

    I guess it'll take at least a few hours of use before we really appreciate the changes. It also looks like there are some 2D experiments waiting in that new staging location - at least I didn't notice them in the package manager before.

    Edit: Had a crash on updating some packages. Could be compiler-related, could be the beta-ness of the editor. Sent a report which is probably still uploading.
     
    Last edited: Mar 28, 2018
    Lu4e likes this.
  3. Player7

    Player7

    Joined:
    Oct 21, 2015
    Posts:
    1,129
    Did everything on the guide.. however step 4.. I don't see a compiler option tab in the pref window...

    package manager shows the incremental compiler is installed for the project.. it does seem faster in compiling though... maybe :)

    annoyance.. it has the "Hold On".. window showing when it recompiling, and that blocks you from hitting the editor play button... which I do all the time after making a change so that it automatically plays the build once it has recompiled.. for now that time saving with Roslyn seems a little irrelevant when I have to wait for it finish just to hit the play button now, :) because even after the Hold On window goes away.. it still has some editor delay where it doesn't have the icon compiling at the bottom status bar.. yet you can't click on anything in the editor for a brief period of time like a couple of seconds, like the play button.. so that ain't great right now.

    Compiling does seem a little faster though, but hard to measure, I tried to revert back by removing the package, but don't forget to close visual studio if you do revert and remove the ScriptAssemblies folder (I dunno why not just have "ScriptAssemblies-roslyn" to make it a little easier to switch compiler instead of it using the same folder as the previous compiler....as I had some roslyn process with a handle on the ScriptAssemblies folder when deleting it, that made Unity think the disk was out of space after restarting Unity, as I couldn't create any files in that folder with VS from previous session still running with some roslyn process.
     
  4. Dom_Laflamme

    Dom_Laflamme

    Unity Technologies

    Joined:
    Sep 25, 2013
    Posts:
    26
    If you don't see a new section after quitting Unity, deleting the ScriptAssemblies folder and restarting, then the incremental compiler is not active.

    What OS are you using?
     
  5. Player7

    Player7

    Joined:
    Oct 21, 2015
    Posts:
    1,129
    I see what is wrong.. you forgot to mention that the player settings for the project need to have the scripting runtime set to .net 4.5 ..not Legacy

    The compiler tab shows up now..my other issues still apply though :)
     
    Jes28 and Dom_Laflamme like this.
  6. Onigiri

    Onigiri

    Joined:
    Aug 10, 2014
    Posts:
    52
    You need to change scripting runtime to version 4.x in player settings
     
  7. Dom_Laflamme

    Dom_Laflamme

    Unity Technologies

    Joined:
    Sep 25, 2013
    Posts:
    26
    my bad, I'll add this to the original post. thanks!
     
  8. SugoiDev

    SugoiDev

    Joined:
    Mar 27, 2013
    Posts:
    190
    Installed and got the Compiler pref menu.
    But compilation fails. Getting this:

    Code (CSharp):
    1. UNetWeaver error: Exception :System.IO.IOException: Sharing violation on path Temp\Vendor.pdb
    2.   at System.IO.File.Delete (System.String path) [0x00073] in <e1a80661d61443feb3dbdaac88eeb776>:0
    3.   at Unity.UNetWeaver.Weaver.Weave (System.String assName, System.Collections.Generic.IEnumerable`1[T] dependencies, Mono.Cecil.IAssemblyResolver assemblyResolver, System.String unityEngineDLLPath, System.String unityUNetDLLPath, System.String outputDir) [0x002cf] in C:\buildslave\unity\build\Extensions\Networking\Weaver\UNetWeaver.cs:1862
    4.   at Unity.UNetWeaver.Weaver.WeaveAssemblies (System.Collections.Generic.IEnumerable`1[T] assemblies, System.Collections.Generic.IEnumerable`1[T] dependencies, Mono.Cecil.IAssemblyResolver assemblyResolver, System.String outputDir, System.String unityEngineDLLPath, System.String unityUNetDLLPath) [0x0004c] in C:\buildslave\unity\build\Extensions\Networking\Weaver\UNetWeaver.cs:1888
    5. UnityEngine.Debug:LogError(Object)
    6. Unity.UNetWeaver.Log:Error(String) (at C:/buildslave/unity/build/Extensions/Networking/Weaver/Program.cs:20)
    7. Unity.UNetWeaver.Weaver:WeaveAssemblies(IEnumerable`1, IEnumerable`1, IAssemblyResolver, String, String, String) (at C:/buildslave/unity/build/Extensions/Networking/Weaver/UNetWeaver.cs:1896)
    8. Unity.UNetWeaver.Program:Process(String, String, String, String[], String[], IAssemblyResolver, Action`1, Action`1) (at C:/buildslave/unity/build/Extensions/Networking/Weaver/Program.cs:34)
    9. UnityEditor.Scripting.ScriptCompilation.EditorCompilationInterface:PollCompilation()
    10.  

    Already deleted everything and did a reimport. Always fails the same way.
    I can see that Unity does indeed have a handle on the pdb.


    It seems that it will hold onto the first pdb it generates. I changed things a bit and it was another one that was held.


    Any ideas?

    Edit: Using b12 on Windows 10 x64 (forgot to include info).
    I removed all assemblies from my project and left only one, to test.
    Fails the same way.

    Edit2: After reimporting the asmdef file a few times, it failed differently:

    Code (CSharp):
    1. UNetWeaver error: Exception :System.InvalidOperationException: Operation is not valid due to the current state of the object.
    2.   at Mono.Cecil.ModuleDefinition.ReadSymbols (Mono.Cecil.Cil.ISymbolReader reader) [0x0002f] in <28cdca1704d2491781795499c297b78b>:0
    3.   at Mono.Cecil.ModuleReader.ReadSymbols (Mono.Cecil.ModuleDefinition module, Mono.Cecil.ReaderParameters parameters) [0x0004a] in <28cdca1704d2491781795499c297b78b>:0
    4.   at Mono.Cecil.ModuleReader.CreateModule (Mono.Cecil.PE.Image image, Mono.Cecil.ReaderParameters parameters) [0x00081] in <28cdca1704d2491781795499c297b78b>:0
    5.   at Mono.Cecil.ModuleDefinition.ReadModule (Mono.Disposable`1[T] stream, System.String fileName, Mono.Cecil.ReaderParameters parameters) [0x0000d] in <28cdca1704d2491781795499c297b78b>:0
    6.   at Mono.Cecil.ModuleDefinition.ReadModule (System.String fileName, Mono.Cecil.ReaderParameters parameters) [0x0006c] in <28cdca1704d2491781795499c297b78b>:0
    7.   at Mono.Cecil.AssemblyDefinition.ReadAssembly (System.String fileName, Mono.Cecil.ReaderParameters parameters) [0x00000] in <28cdca1704d2491781795499c297b78b>:0
    8.   at Unity.UNetWeaver.Weaver.Weave (System.String assName, System.Collections.Generic.IEnumerable`1[T] dependencies, Mono.Cecil.IAssemblyResolver assemblyResolver, System.String unityEngineDLLPath, System.String unityUNetDLLPath, System.String outputDir) [0x0000f] in C:\buildslave\unity\build\Extensions\Networking\Weaver\UNetWeaver.cs:1763
    9.   at Unity.UNetWeaver.Weaver.WeaveAssemblies (System.Collections.Generic.IEnumerable`1[T] assemblies, System.Collections.Generic.IEnumerable`1[T] dependencies, Mono.Cecil.IAssemblyResolver assemblyResolver, System.String outputDir, System.String unityEngineDLLPath, System.String unityUNetDLLPath) [0x0004c] in C:\buildslave\unity\build\Extensions\Networking\Weaver\UNetWeaver.cs:1888
    10. UnityEngine.Debug:LogError(Object)
    11. Unity.UNetWeaver.Log:Error(String) (at C:/buildslave/unity/build/Extensions/Networking/Weaver/Program.cs:20)
    12. Unity.UNetWeaver.Weaver:WeaveAssemblies(IEnumerable`1, IEnumerable`1, IAssemblyResolver, String, String, String) (at C:/buildslave/unity/build/Extensions/Networking/Weaver/UNetWeaver.cs:1896)
    13. Unity.UNetWeaver.Program:Process(String, String, String, String[], String[], IAssemblyResolver, Action`1, Action`1) (at C:/buildslave/unity/build/Extensions/Networking/Weaver/Program.cs:34)
    14. UnityEditor.Scripting.ScriptCompilation.EditorCompilationInterface:TickCompilationPipeline(EditorScriptCompilationOptions, BuildTargetGroup, BuildTarget)
    15.  
    But on the compilation console, it's the same

    Code (CSharp):
    1. Internal compiler error: System.IO.IOException: Sharing violation on path C:\Users\Fausto\AppData\Local\Temp\qm8f2cig.h4e\Vendor.pdb" or "V:/LOSTALLOY/Aftertile/Unity3D/Temp/Vendor.pdb
    2.   at System.IO.File.Copy (System.String sourceFileName, System.String destFileName, System.Boolean overwrite) [0x00192] in <e1a80661d61443feb3dbdaac88eeb776>:0
    3.   at UnityEditor.Compilation.IncrementalCompiler.Compilation+<Run>d__22.MoveNext () [0x00399] in <b677897e5ef74c96b18b149e35f2365a>:0
    4. Vendor.dll 7871ms  re-parsed: source(2271) metadata(0) concurrent compilations(1)
     
    Last edited: Mar 28, 2018
  9. DoctorShinobi

    DoctorShinobi

    Joined:
    Oct 5, 2012
    Posts:
    62
    Wow, this is great. Happy birthday to all of us I guess.
     
    ModLunar, Lu4e and Dom_Laflamme like this.
  10. Dom_Laflamme

    Dom_Laflamme

    Unity Technologies

    Joined:
    Sep 25, 2013
    Posts:
    26
    ok yeah this is indeed a side-effect of using the incremental compiler, since it generates portable pdbs and causes Unity to try to load those.

    I'll investigate and reply back.
    In the mean time I think the only solution is to disable the UNet module.
     
  11. orb

    orb

    Joined:
    Nov 24, 2010
    Posts:
    2,950
    I considered the .NET 4.x requirement obvious (if there's talk about C# 7.x, you can bet it there's the latest .NET involved). I know there have been issues with .NET 4.x on the Windows side of Unity, but on macOS I have been using it without any issues in Unity 2017.x. Betas with experimental packages on top is a whole different matter though!
     
  12. SugoiDev

    SugoiDev

    Joined:
    Mar 27, 2013
    Posts:
    190
    Is it possible to disable it? com.unity.unet?
    Edit: com.unit.unet doesn't exist. Not sure how to disable it to test.
     
  13. Enzi

    Enzi

    Joined:
    Jan 28, 2013
    Posts:
    72
    Works good in my ECS demo, big thanks!
    Does the current Entities 0.0.11 version already utilize ref returns? I don't think I saw any in code. How easy would it be to add for me? Just with "return ref data;" or is there more to it?

    With ref returns we can return addreses to structs and modify them directly in systems/jobs without writing back a new struct or make an update call. Is this correct?
     
  14. Peter77

    Peter77

    Joined:
    Jun 12, 2013
    Posts:
    2,753
    These are great results, innovative idea!

    If you write your own compiler, how likely is it, that you put yourself in a position where you're stuck with this compiler and can't benefit from upgrades of the current compiler technology? It would be a bummer, if this new tech causes a freeze where you can't upgrade the language/compiler to the latest version, like we experienced in the past with your Mono fork.

    Is this a long time feature, that is going to be supported by a dedicated team "forever"? New tech in Unity is often great on the surface, but if you dig deeper, you find issues and it occurred sometimes in the past, that UT don't seem too interested to "finish the work" to iron out all the problems, which would be a tremendous issue regarding compiler tech.
     
  15. snlehton

    snlehton

    Joined:
    Jun 11, 2010
    Posts:
    95
    This does help greatly with the compilation of scripts, I bet. However, it does not help with the reserialization of assets after the compilation, which in my tests can take up to 70% of the total "script compilation time"...

    This of course varies from project to project, but at least for us the actual C# compilation time is not the problem.
     
  16. SugoiDev

    SugoiDev

    Joined:
    Mar 27, 2013
    Posts:
    190
    This is just a modified Roslyn.
    If all fails, you can just drop alexzzzz's compiler replacement and and at worst get poorer compilation times.
    Roslyn is a breeze to integrate and it's just a few lines of code to get a fully working compiler wrapper.
    As long as Unity isn't modifying the generated code (or at least not depending on modifications therein), we should be safe.
     
    johnnyt likes this.
  17. SugoiDev

    SugoiDev

    Joined:
    Mar 27, 2013
    Posts:
    190
    I think the same. The biggest criminal is the actual assembly reload time, and a large chunk of that time will be spent on serialization/deserialization on projects with lots of serialized stuff.

    But this compiler really is a great first step and will favor splitting the code into multiple small assemblies that have no dependencies (so you get parallel compilation benefits).
     
  18. Enzi

    Enzi

    Joined:
    Jan 28, 2013
    Posts:
    72
    Does anyone else have the issue in Visual Studio 2017 and the new compiler that reference dlls and namespaces like Unity.Collections are not loaded in the project?
     
  19. Carpet_Head

    Carpet_Head

    Joined:
    Nov 27, 2014
    Posts:
    61
    Seems like 2018 will be the year where unity finally gets it's act together. Looking forward to more
     
  20. Creepgin

    Creepgin

    Joined:
    Dec 14, 2010
    Posts:
    91
    I think I encountered the same with VS 2017. Because VS is acting weird with 2018 beta in general, I didn't give it too much thought.

    Switching to vscode (which is using omnisharp) fixed the loading for me.
     
  21. Player7

    Player7

    Joined:
    Oct 21, 2015
    Posts:
    1,129
    Maybe you did, anyway 4.x had some issues on android last time I checked earlier during 2018.1 and 2017.3.. I guess I'm about to find out if they are still issues from the last time I was trying net 4.x
     
  22. RealMTG

    RealMTG

    Joined:
    Jul 27, 2013
    Posts:
    212
    Gonna add some from what I experienced after around just 10 minutes of trying it out.
    Trying to import it wasn't as smooth as I had hoped but still manageable. I had Unity open and that freaked out a bit. Shut it down and removed the entire Library folder, just to be safe. Worked when I started it again.
    However, there were still some things I noticed.
    Every recompile caused an error to be thrown:
    System.ArgumentException: Illegal characters in path.
    .
    There also appears to be a console window opening very quickly every recompile.
    Lastly, as someone mentioned just a bit above here, Visual Studio 2017 started to act up with it enabled. Nothing was loaded properly. Like, all classes, attributes, and everything was just white and Intelisense didn't work at all.
    But the speeds were nice at least.

    I'm not sure if it's just "general beta stuff" or if I did something really bad. But for now, I personally can't use it.
     
  23. RafaelF82

    RafaelF82

    Joined:
    Oct 28, 2013
    Posts:
    97
    Just tested on my project and have no noticeable difference.

    Performance was far from what was shown in the first post graphic, still slow to compile minor changes (as adding a public float).
     
  24. jbevain

    jbevain

    Microsoft

    Joined:
    Feb 22, 2012
    Posts:
    136
    Make sure you're up to date with VS 2017. You'll need to have at least the 15.6.4 version to properly handle the changes of Unity 2018.
     
  25. Dmitriy-Yukhanov

    Dmitriy-Yukhanov

    Joined:
    Jul 27, 2012
    Posts:
    1,108
    Awesome new feature is somewhere near us, unbelievable!
    Thanks for working on this, guys!

    One bug so far I've noticed, when I went through all steps from the import instruction, and re-opened project I have these errors in console repeating 6 times:

    Code (CSharp):
    1. System.ArgumentException: Illegal characters in path.
    2.   at System.IO.Path.ChangeExtension (System.String path, System.String extension) [0x00013] in <e1a80661d61443feb3dbdaac88eeb776>:0
    3.   at UnityEditor.Compilation.RoslynIncrementalCompiler.InvokeCompiler (System.String[] unityCompilerArguments, UnityEditor.Compilation.CustomCompiler+OnCompilerMessage onMessage, UnityEditor.Compilation.CustomCompiler+OnCompilationDone onDone) [0x000fc] in <105c6264c1664693a0a8be2e12a50667>:0
    4. System.Threading.ThreadHelper:ThreadStart()
    I have only 1 script in the project and have this path to the project:
    C:\Users\focus\Desktop\Incremental Compiler Test

    Changing path to the
    C:\Users\focus\Desktop\IncrementalCompilerTest

    Fixed this problem. Looks like it doesn't likes spaces in the path.

    P.S. Cyrillic chars are not welcomed too - having same errors when using path
    C:\Users\focus\Desktop\IncrementalCompilerTestРаз
     
    Last edited: Mar 28, 2018
    thom_cat_ likes this.
  26. Dmitriy-Yukhanov

    Dmitriy-Yukhanov

    Joined:
    Jul 27, 2012
    Posts:
    1,108
    I didn't noticed any console windows.
    Are you having this option disabled?
    upload_2018-3-29_0-30-9.png
     
  27. Dmitriy-Yukhanov

    Dmitriy-Yukhanov

    Joined:
    Jul 27, 2012
    Posts:
    1,108
    Out vars are working, wee! =D
    upload_2018-3-29_0-34-32.png

    IntelliSense working fine, but code syntax coloration is incorrect (Debug on screenshot is white but it should have the same color as NewBehaviourScript):
    upload_2018-3-29_0-42-51.png
     
    Last edited: Mar 28, 2018
  28. RealMTG

    RealMTG

    Joined:
    Jul 27, 2013
    Posts:
    212
    That actually might be the case, now when I think about it. I remember checking out the preferences and enabling that and then forgot about it. My bad!
     
  29. Enzi

    Enzi

    Joined:
    Jan 28, 2013
    Posts:
    72
    I've got 15.6.4 VS and Visual Studio Tools for Unity 3.6.0.5. I updated before posting but there was no difference.
     
  30. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    2,013
    @elfuego Compilation doesn't even show up, it's definitely sub half second - WOW.
    Now here comes the flip side of this golden coin: it's so fast that all the editor stuttering that weren't noticeable before show up and climb that refresh rate far beyond 0.5 second - this is jarring. Maybe I'm extra sensitive to lag after doing 2 days of electronic (bc. it's instant) but still lag = :mad:.
    Not your team, so if the editor team wants to fix those things, here is a case # coming up for tracking porpoise: 1019696
     
    Kolyasisan, Griz and Dmitriy-Yukhanov like this.
  31. MorCompediaNet

    MorCompediaNet

    Joined:
    Jan 22, 2017
    Posts:
    21
    Is this planned to stick for the release of 2018.1, or is it gonna be like the C# 6 update that was only available in beta releases for a duration?
     
    SugoiDev likes this.
  32. TJHeuvel-net

    TJHeuvel-net

    Joined:
    Jul 31, 2012
    Posts:
    361
    Could we write a warning that tells us that we forgot to call an IEnumerator with StartCoroutine? That would save me a lot of embarrassment.
     
    Stormy102 and Peter77 like this.
  33. SugoiDev

    SugoiDev

    Joined:
    Mar 27, 2013
    Posts:
    190
    Since this is an separate package, it should stick past the betas (even if only in the staging repo).
     
  34. Scorr

    Scorr

    Joined:
    Jul 2, 2013
    Posts:
    43
    Is there a way we can get the incremental compiler's state? e.g. normally you could use EditorApplication.isCompiling but that doesn't seem to get used anymore with this package.
     
  35. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    338
    @elfuego, thanks for letting us try out this awesome incremental compiler. Before that there is REST server feature that can sync Unity and IDE changes seamlessly. So, IDEs will not have the problem of keep reloading same project file issue anymore when you just create a new C# script file. I see MonoDevelop has been phased out and it's removed from the roadmap but I wonder whether this compiler will still working on this REST server feature for other IDEs like Visual Studio and Rider?
     
  36. z00n

    z00n

    Joined:
    Nov 24, 2009
    Posts:
    44
    Msvs 15.6.4 and Rider can't build solution - wrong path to compiler:
    Code (csharp):
    1.  <Target Name="BeforeBuild">
    2.     <PropertyGroup>
    3.       <ResponseFile>$(SolutionDir)$(AssemblyName).rsp</ResponseFile>
    4.       <CompilerPath>$(SolutionDir)Packages\com.unity.incrementalcompiler\.bin\Unity.IncrementalCompiler.exe</CompilerPath>
    5.       <CompilerPort>49920</CompilerPort>
    6.     </PropertyGroup>
    7.     <Message Text="Connecting to Unity Incremental Compiler on port $(CompilerPort)" Importance="High" />
    8.     <Exec Command="$(CompilerPath) --port=$(CompilerPort) @$(ResponseFile)" />
    9.   </Target>
    10.  
    result:
    Code (csharp):
    1.  
    2. Build started 3/29/2018 2:10:26 PM.
    3.      1>Project "C:\xxx\yyy\Assembly-CSharp.csproj" on node 1 (build target(s)).
    4.      1>BeforeBuild:
    5.          Connecting to Unity Incremental Compiler on port 49920
    6.          C:\xxx\yyy\Packages\com.unity.incrementalcompiler\.bin\Unity.IncrementalCompiler.exe --port=49920
    7.          @C:\xxx\yyy\Assembly-CSharp.rsp
    8.          The system cannot find the path specified.
    9.      1>C:\xxx\yyy\Assembly-CSharp.csproj(655,5): error MSB3073: The command "C:\xxx\yyy\Packages\com.unity
    10.     .incrementalcompiler\.bin\Unity.IncrementalCompiler.exe --port=49920 @C:\xxx\yyy\Assembly-CSharp.rsp" exited with
    11.      code
    12.      
    13.      3
    14.      .
    15.      1>Done Building Project "C:\xxx\yyy\Assembly-CSharp.csproj" (build target(s)) -- FAILED.[/SIZE]
    16.  
     
  37. nxrighthere

    nxrighthere

    Joined:
    Mar 2, 2014
    Posts:
    380
    Finally, a new incremental compiler based on Roslyn. How long I've been waiting for this... Thank you.

    Now I only dream about integration with .NET Core.
     
    Last edited: Mar 29, 2018
    Kichang-Kim likes this.
  38. Ivy-SM

    Ivy-SM

    Joined:
    Apr 18, 2013
    Posts:
    22
    I've got a similar problem. Were you able to fix it?
     
  39. SugoiDev

    SugoiDev

    Joined:
    Mar 27, 2013
    Posts:
    190
    I think it is working normally on my project. The editor depends on that to know when to reload the assemblies, I believe.
    Maybe your project is just recompiling super fast!
     
  40. JakubSmaga

    JakubSmaga

    Joined:
    Aug 5, 2015
    Posts:
    399
    Stuck on "Compiling scripts..." for around 6 hours after editing manifest. (Tried when Unity was and wasn't running)
     
  41. SugoiDev

    SugoiDev

    Joined:
    Mar 27, 2013
    Posts:
    190
    Is the editor open or is it stuck before the editor opens (in the "compiling custom assemblies" step)?
    If the editor actually opens, you might have hit the issue with the "sharing violation" in a pdb file. A fix for that should arrive soon.

    If the editor isn't even opening, try closing (or killing) it and deleting the Library/ScriptAssemblies folder once more. Then open again and let it compile.

    If you can get it to open, go to Editor -> Preferences -> Compiler and tick "Show console". A console will be shown when you compile with a bit more information on what the compiler is doing. Maybe you can get some info from it.
     
  42. JakubSmaga

    JakubSmaga

    Joined:
    Aug 5, 2015
    Posts:
    399
    When I edit the file while the editor is open it's stuck at "Compiling scripts...", If I'll open the editor with the file changed the window just shows "Starting up package manager", then "Compiling scripts..." and it's just stuck. I'll try to delete Library/ScriptAssemblies again.
     
  43. SugoiDev

    SugoiDev

    Joined:
    Mar 27, 2013
    Posts:
    190
    @JacobSmaga

    With the Editor closed, did you try deleting the ScriptAssemblies folder?
    It's in the Library folder (the Library folder is a sibling of the Assets folder).
    Delete Library/ScriptAssemblies and try opening the Editor again.


    As a last resort, you might try renaming or moving the entire Library folder and let Unity reimport the project (might take a long time for large projects).

    It if still fails, you can delete the new Library folder and put your old one back.
     
  44. JakubSmaga

    JakubSmaga

    Joined:
    Aug 5, 2015
    Posts:
    399
    Tried it, still doesn't work.

    Trying that right now, thanks for your help.
     
  45. SugoiDev

    SugoiDev

    Joined:
    Mar 27, 2013
    Posts:
    190
    @JacobSmaga It might be too late, but did you try reading the Editor.log to see if it gave any clues?
    I never had any luck with the log for those cases, but maybe you'll have.


    Let us know if it works!
     
  46. SugoiDev

    SugoiDev

    Joined:
    Mar 27, 2013
    Posts:
    190
    A fix/workaround is on the way!
    I kinda fixed it by patching the weaver's dll, but it's best to wait for an actual fix instead of following this dark path.
     
  47. Dom_Laflamme

    Dom_Laflamme

    Unity Technologies

    Joined:
    Sep 25, 2013
    Posts:
    26
    Ok, thanks for everyone for the amazing feedback and enthusiastic responses! Keep it coming :)
    I'm releasing 0.0.29 (please update your manifests) with some bug fixes that should address the following issues:


    fixed the "space in path" problem, as well as projects with non-ASCII characters. Let me know if you still get issues.

    I fixed a race condition that was causing problem copying assemblies from Temp/ to Library/ScriptAssemblies. Let me know if you still get this in 0.0.29. However for the sharing violation of the PDB file, it's a little more complicated to fix. We are working on a fix in UNetWeaver as we speak. We'll have to roll it out in the next Unity beta. Other than patching the offending UNet assembly yourself, the only workaround at this point is to delete the UNet module dll altogether. I'll post here when I have more information.

    The incremental compiler should have no effect on EditorApplication.isCompiling or any other CompilationPipeline-related APIs ...other than indirectly in the sense that it could be compiling much faster and your code might "miss" it.

    I was able to reproduce a similar issue. This was happening when the compiler client (the part in Unity) was throwing an exception that was not handled. The compilation pipeline was then never informed about the failure. I fixed it and it should now revert to the built-in compiler when it fails in this way. It will also print out the exception information. If you see a message saying "RoslynIncrementalCompiler client threw an exception. As a result the built-in compiler was used..." please let me know. This would indicate that there's a failure in the client that I will need to fix.

    I fixed the .csproj generation. Compiling directly from Rider and Visual Studio should work now.
     
    GabrieleUnity, Creepgin, z00n and 2 others like this.
  48. pvloon

    pvloon

    Joined:
    Oct 5, 2011
    Posts:
    567
    Wooh, this is very exciting! I can't tell you how happy a quick compile -> see changes iteration scheme would make me :)

    Few problems however:
    ->Breaks syntax highlighting for me too (latest VS, latest unity plugin)
    ->With or without show console, always get a popup 'Compiling Scripts' when switching to unity.
    ->Like others have expressed, ReloadAssembly (& others!) are still the main problem:

    upload_2018-3-29_11-53-13.png

    There's probably a lot more work before we get to 500ms between code->change.

    I also wonder, could you elaborate on "which means we can do things (or skip things) other compilers cannot." - what kind of things?

    Lastly - you mention writing custom compilation rules. Is that in already? Are these like Roslyn Analyzers, but specifically for unity?
     

    Attached Files:

    SirIntruder likes this.
  49. Dmitriy-Yukhanov

    Dmitriy-Yukhanov

    Joined:
    Jul 27, 2012
    Posts:
    1,108
    Thanks for quick reaction to our reports, @elfuego !
    BTW it could be helpful for others if you would update initial post where you have initialization steps with new version at the manifest so people will get latest build and will not need to look for the new version in the thread ^^
     
  50. alexzzzz

    alexzzzz

    Joined:
    Nov 20, 2010
    Posts:
    1,357
    RoslynCSProjectAssetPostprocessor adds CSHARP_7_2 and CSHARP_7_OR_LATER defines but sets LangVersion to 7.1 instead of 7.2 or 'latest'.

    I noticed the new version in the package manager even before reading the corresponding post. Glory to Package Manager!
     
    Last edited: Mar 29, 2018