Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Official .NET scripting backend and Visual Studio 2017.3 incompatibility

Discussion in 'Windows' started by Tautvydas-Zilys, Aug 12, 2017.

  1. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,640
    Hi,

    we very recently discovered that there is a compatibility issue between Unity and upcoming Visual Studio 2017 update 3 when targeting UWP, using .NET scripting backend (IL2CPP scripting backend is not affected) and building generated Visual Studio project. It shows itself as this exception in the output window:

    Code (csharp):
    1. 1>------ Build started: Project: AppTest, Configuration: Debug x86 ------
    2. 1>  AppTest -> D:\AppTest\AppTest\bin\x86\Debug\AppTest.exe
    3. 1>  UnityWSAPlayerDir "C:\Program Files\Unity\Editor\Data\PlaybackEngines\MetroSupport\".
    4. 1>  UnityProjectDir "".
    5. 1>  Copying unprocessed assemblies...
    6. 1>  Running AssemblyConverter...
    7. 1>  System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
    8. 1>     at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
    9. 1>     at UnityEditor.Scripting.Compilers.NuGetPackageResolver.Resolve()
    10. 1>     at Unity.UWPAssemblyResolver..ctor(String projectLockFile, String desiredUWPSDKVersion)
    11. 1>     at Unity.OperationContext.SetPlatform(Platform platform, String projectLockFile, String uwpSDK)
    12. 1>     at Unity.ParseArgsStep.Execute()
    13. 1>     at Unity.Step.Execute(OperationContext operationContext, IStepContext previousStepContext)
    14. 1>     at Unity.Operation.Execute()
    15. 1>     at Unity.Program.Main(String[] args)
    16. 1>D:\AppTest\AppTest\AppTest.csproj(257,9): error MSB3073: The command ""D:\AppTest\Unity\Tools\AssemblyConverter.exe" -platform=uap -lock="D:\AppTest\AppTest\project.lock.json" -bits=32 -configuration=Debug -removeDebuggableAttribute=False -uwpsdk=10.0.15063.0 -path="." -path="C:\Program Files\Unity\Editor\Data\PlaybackEngines\MetroSupport\Players\UAP\dotnet\x86\Debug" "D:\AppTest\AppTest\UnityEngine.dll" "D:\AppTest\AppTest\UnityEngine.Analytics.dll" "D:\AppTest\AppTest\nunit.framework.dll" "D:\AppTest\AppTest\UnityEngine.UI.dll" "D:\AppTest\AppTest\UnityEngine.Networking.dll"" exited with code 1.
    17. ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
    We will soon be releasing patch releases to fix that, backporting it all the way to Unity 5.5 (which was the first release to even support VS 2017 when building for UWP). Until then, if you're targeting UWP and using .NET scripting backend, we suggest refraining from upgrading to Visual Studio 2017.3 (which got released on August 14th).

    Here is the status of patches with the fix:

    5.5 version with the fix: 5.5.4p5
    5.6 version with the fix: 5.6.3p2
    2017.1 version with fix: 2017.1.0p5
    2017.2 version with fix: 2017.2.0b7
     
    Last edited: Dec 15, 2017
  2. ei2kpi

    ei2kpi

    Joined:
    Apr 26, 2014
    Posts:
    6
    Noooooooooooooo!!!!! My VS2017 got upgraded automatically because I had to install a new component.... Does anyone know how to downgrade to version 15.2? I don't mind uninstalling the entire thing and reinstalling... but I cant seem to find an installer for the specific 15.2 version

    Can't believe my luck :(
     
  3. ei2kpi

    ei2kpi

    Joined:
    Apr 26, 2014
    Posts:
    6
    TamBui and skullthug like this.
  4. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,640
    Yeah, sorry you ran into this. Workarounds (other than reinstalling VS2017 from scratch) involve using VS2015 to build the generated project, using IL2CPP temporarily (unless your project doesn't build with it) or using this trick a person on HoloLens forums found.
     
    ei2kpi likes this.
  5. ei2kpi

    ei2kpi

    Joined:
    Apr 26, 2014
    Posts:
    6
    All fixed on downgrading! Thanks!
     
  6. TamBui

    TamBui

    Joined:
    Jun 29, 2017
    Posts:
    9
    Just my luck, this issue hit me like a ton of bricks right before an important demo on Friday, when my VS2017 did an update when I didn't mean to (I just wanted to see what components were installed but it wouldn't let me until I updated it). I spent all day trying to install VS2017 and Unity 2017.2.0b8 on other build systems, only to find they all had this same error. Well now I know what I need to do when I get back to work next week. Thanks for the confirmation, though! It puts my mind at ease this weekend. :)
     
  7. saurabh_cv

    saurabh_cv

    Joined:
    Aug 20, 2017
    Posts:
    2
    I am facing the same issue, did it work for you ?
     
  8. TamBui

    TamBui

    Joined:
    Jun 29, 2017
    Posts:
    9
    @saurabh_cv I haven't tried it yet. However, it looks like @ei2kpi provided the links needed to backtrack VS2017 to version 15.0 to workaround the issue for now. Unfortunately, the downside is that it will require an uninstall/re-install of VS2017 which will set you back about an hour or two (and a keen eye to make sure that it doesn't attempt to update itself again).
     
  9. Handosa

    Handosa

    Joined:
    Aug 21, 2017
    Posts:
    1
    Hi all,

    No need to downgrade Visual Studio. One way to eliminate the problem is to edit the "project.lock.json" file and replace each occurrence of "UAP,Version=v10.0.10240" with "UAP,Version=v10.0". Note that each time you rebuild the VS project the "project.lock.json" file will be recreated and you will need to redo the edit.

    For your convenience, you may develop a quick tool to do the edit. I have created a console application and all I need now is to copy the EXE file next to the "project.lock.json" file and run the EXE each time I need to do the edit. The source code for the console application is:

    Code (CSharp):
    1. namespace FixVersion
    2. {
    3.     class Program
    4.     {
    5.         static void Main(string[] args)
    6.         {
    7.             try
    8.             {
    9.                 string content = string.Empty;
    10.                 using (StreamReader reader = new StreamReader(AppDomain.CurrentDomain.BaseDirectory + @"\project.lock.json"))
    11.                 {
    12.                     content = reader.ReadToEnd();
    13.                     content = content.Replace("UAP,Version=v10.0.10240", "UAP,Version=v10.0");
    14.                     reader.Close();
    15.                 }
    16.  
    17.                 using (StreamWriter writer = new StreamWriter(AppDomain.CurrentDomain.BaseDirectory + @"\project.lock.json"))
    18.                 {
    19.                     writer.Write(content);
    20.                     writer.Close();
    21.                 }
    22.  
    23.                 Console.WriteLine("DONE.");
    24.             }
    25.             catch(Exception ex)
    26.             {
    27.                 Console.WriteLine("ERROR: " + ex.Message);
    28.             }
    29.  
    30.             Console.WriteLine("Press any key to exit.");
    31.             Console.ReadKey();
    32.         }
    33.     }
    34. }
    Good luck :)
     
  10. DaTruAndi

    DaTruAndi

    Joined:
    Apr 14, 2017
    Posts:
    15
    I run into this when building the project to deploy after patching assemblies stage 2 with 2017.2.0b8:
    Code (CSharp):
    1. KeyNotFoundException: The given key was not present in the dictionary.
    2. System.ThrowHelper.ThrowKeyNotFoundException () (at <9c9f068c46c64ffd91fda7af157b4d15>:0)
    3. System.Collections.Generic.Dictionary`2[TKey,TValue].get_Item (TKey key) (at <9c9f068c46c64ffd91fda7af157b4d15>:0)
    4. MetroCSharpVisualStudioSolutionCreator.WriteSolutionFile (System.String solutionFileName, UnityEditor.Scripting.ScriptCompilation.ScriptAssembly[] csharpAssemblies) (at C:/buildslave/unity/build/PlatformDependent/MetroPlayer/Extensions/Managed/MetroCSharpVisualStudioSolutionCreator.cs:166)
    5. MetroCSharpVisualStudioSolutionCreator.CreateSolutionFileFrom () (at C:/buildslave/unity/build/PlatformDependent/MetroPlayer/Extensions/Managed/MetroCSharpVisualStudioSolutionCreator.cs:722)
    6. PostProcessWSA.CreateVisualStudioSolution () (at C:/buildslave/unity/build/PlatformDependent/MetroPlayer/Extensions/Managed/PostProcessWSA.cs:320)
    7. PostProcessWinRT.Process () (at C:/buildslave/unity/build/PlatformDependent/WinRT/SharedSources/CSharp/PostProcessWinRT.cs:237)
    8. UnityEditor.WSA.BuildPostprocessor.DoPostProcess (UnityEditor.Modules.BuildPostProcessArgs args) (at C:/buildslave/unity/build/PlatformDependent/MetroPlayer/Extensions/Managed/ExtensionModule.cs:142)
    9. UnityEditor.WSA.BuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args) (at C:/buildslave/unity/build/PlatformDependent/MetroPlayer/Extensions/Managed/ExtensionModule.cs:149)
    10. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
    11.  
    Note that I have "Unity C# Projects" and "Development Build" both active.
    It seems to be the "Unity C# Projects" that triggers it.
     
    Last edited: Aug 21, 2017
  11. DaTruAndi

    DaTruAndi

    Joined:
    Apr 14, 2017
    Posts:
    15
    My project.lock.json only ever had UAP,Version=v10.0 - nothing of the likes of a specific version (even though I build for version 14393) - still it does not work. So I am not sure that this fix does anything really. Maybe only in a specific type of configuration?
     
  12. AccentDave

    AccentDave

    Joined:
    Nov 16, 2015
    Posts:
    43
    I'm seeing the same as DaTruAndi. Version 10.0 in the project.lock.json. VS version 15.2
     
  13. LancelotSoftware

    LancelotSoftware

    Joined:
    Jun 11, 2016
    Posts:
    2
    @DaTruAndi @AccentDave That issue is unrelated to the OP's problem. What you're experiencing is a known issue since B4 and it's still present in B8. Hopefully, they'll fix it soon, but it's not a show stopper. You can still build, but you won't be able to debug the scripts at runtime in VS.
     
  14. AccentDave

    AccentDave

    Joined:
    Nov 16, 2015
    Posts:
    43
    I cannot build. I get a ton of errors, this one must be telling:?
    error CS0518: Predefined type 'System.Object' is not defined or imported
     
  15. TamBui

    TamBui

    Joined:
    Jun 29, 2017
    Posts:
    9
    @Handosa That worked perfectly! Thank you for saving me from having to downgrade Visual Studio.
     
  16. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,640
    This isn't related. I believe you're hitting a known issue in "Unity C# Projects" checkbox in 2017.2 beta. It is fixed in a future beta.
     
  17. kkostkova

    kkostkova

    Joined:
    Jul 28, 2017
    Posts:
    2
    Hi,

    are there any command line parameters I could you while installing VS2017 that would install an older version? I have a vs_enterprise.exe installer, which installs the latest version. Through the links provided above, I can download only a trial version of the VS2017 enterprise, which would solve the problem only temporarily.

    Thanks.
     
  18. Deleted User

    Deleted User

    Guest

    I have a completely different behavior. Using Unity 2017.2.0b8, and Visual Studio 2017.3.2

    HoloLens/UWP project builds from Unity without errors. The Visual Studio project created from Unity also builds and deploys without errors. However, any of the scripts attached to GameObjects do not initialize/execute. The scripts do execute in the Editor.
     
  19. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,640
    Can you make a new thread for unrelated issues?
     
  20. Deleted User

    Deleted User

    Guest

  21. kaifanla

    kaifanla

    Joined:
    Aug 29, 2017
    Posts:
    2
    Though it is a little troubling for replacing the project.lock.json each time the project is rebuilt, it works. thanks.
    I'm using Unity 5.6, VS 2017 15.3.
     
    santosluiz00 likes this.
  22. santosluiz00

    santosluiz00

    Joined:
    May 30, 2017
    Posts:
    7
    After 2 days trying solve it, your solution works for me. Thanks a lot Kaifanla!
     
  23. kaifanla

    kaifanla

    Joined:
    Aug 29, 2017
    Posts:
    2
    handshake;D
     
  24. Gamrek

    Gamrek

    Joined:
    Sep 28, 2010
    Posts:
    164
    I have updated to Unity 2017.1 p5, but this issue still exist.

    Code (CSharp):
    1. Severity    Code    Description    Project    File    Line    Suppression State
    2. Error    CS0006    Metadata file 'D:\My Work\HoloLens Project\Empty\GeneratedProjects\UWP\Assembly-CSharp-firstpass\bin\x86\Debug\Assembly-CSharp-firstpass.dll' could not be found    Assembly-CSharp    D:\My Work\HoloLens Project\Empty\GeneratedProjects\UWP\Assembly-CSharp\CSC    1    Active
    3.  
    4.  
    5. Severity    Code    Description    Project    File    Line    Suppression State
    6. Error        The command ""D:\My Work\HoloLens Project\Empty\Unity\Tools\SerializationWeaver\SerializationWeaver.exe" "D:\My Work\HoloLens Project\Empty\GeneratedProjects\UWP\Assembly-CSharp-firstpass\bin\x86\Debug\Unprocessed\Assembly-CSharp-firstpass.dll" "-pdb" "-verbose" "-unity-engine=D:\My Work\HoloLens Project\Empty\HoloLens Empty\Unprocessed\UnityEngine.dll" "D:\My Work\HoloLens Project\Empty\GeneratedProjects\UWP\Assembly-CSharp-firstpass\obj\x86\Debug\x86\Debug" "-lock=D:\My Work\HoloLens Project\Empty\GeneratedProjects\UWP\Assembly-CSharp-firstpass\project.lock.json" "@D:\My Work\HoloLens Project\Empty\GeneratedProjects\UWP\Assembly-CSharp-firstpass\SerializationWeaverArgs.txt" "-additionalAssemblyPath=D:\My Work\HoloLens Project\Empty\HoloLens Empty\Unprocessed" "-unity-networking=D:\My Work\HoloLens Project\Empty\HoloLens Empty\Unprocessed\UnityEngine.Networking.dll"" exited with code 1.    Assembly-CSharp-firstpass    D:\My Work\HoloLens Project\Empty\GeneratedProjects\UWP\Assembly-CSharp-firstpass\Assembly-CSharp-firstpass.csproj    192  
    7.  
    8. Severity    Code    Description    Project    File    Line    Suppression State
    9. Error        Type universe cannot resolve assembly: System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a.    HoloLens Empty          
    10.  
    11.  
    12. Severity    Code    Description    Project    File    Line    Suppression State
    13. Error        Cannot resolve Assembly or Windows Metadata file 'System.Runtime.dll'    HoloLens Empty    D:\My Work\HoloLens Project\Empty\HoloLens Empty\HoloLens Empty.csproj    
     
    Last edited: Aug 30, 2017
  25. Creatovi

    Creatovi

    Joined:
    Sep 4, 2015
    Posts:
    3

    Visual Studio 2017 released a new version yesterday (15.3.3) and it seems solved this build issue. Before that, I tried 15.3.2 with Unity 5.6.1f1, 2017.1.0f3, 2017.1.0p5, 2017.2.0b8, none of them works.
    Now with Unity 2017.1.0p5 and VS2017 15.3.3, the project can be built.
     
    sebrk_hiq likes this.
  26. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,640
    Please paste the contents of the output window. It could be you're running into a different issue.
     
  27. sebrk_hiq

    sebrk_hiq

    Joined:
    Jul 10, 2017
    Posts:
    23
    I can also affirm that 2017.1.0p5 and VS2017 15.3.3 works. I could not wait for 5.6 updates so I made a complete makeover updating Unity, VS and MixedRealityToolkit. So far so good.
     
  28. Gamrek

    Gamrek

    Joined:
    Sep 28, 2010
    Posts:
    164
    I updated to VS2017 15.3.3 build an empty project with 2017.1.0 p5 and still can't build anything, this is what appears on output panel:

    Code (CSharp):
    1. 1>------ Build started: Project: HoloLens Empty, Configuration: Debug x86 ------
    2. 1>D:\My Work\HoloLens Project\Empty\HoloLens Empty\HoloLens Empty.csproj : XamlCompiler error WMC1006: Cannot resolve Assembly or Windows Metadata file 'System.Runtime.dll'
    3. 1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Microsoft\WindowsXaml\v15.0\8.2\Microsoft.Windows.UI.Xaml.Common.targets(266,5): Xaml Internal Error error WMC9999: Type universe cannot resolve assembly: System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a.
    4. ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
    5. ========== Deploy: 0 succeeded, 0 failed, 0 skipped ==========
    6.  
    I am assuming I have the correct setup under Player Setting and Build Setting?
     

    Attached Files:

  29. DrunkReaperMatt

    DrunkReaperMatt

    Joined:
    Feb 11, 2013
    Posts:
    38
    What is your scripting backend? IL2CPP or .Net
     
  30. Gamrek

    Gamrek

    Joined:
    Sep 28, 2010
    Posts:
    164
    always .NET
     
  31. Mr-KoSiarz

    Mr-KoSiarz

    Joined:
    Apr 22, 2017
    Posts:
    4
    I can confirm that 5.6.3p2 is working with VS 2017.3. Thx
     
  32. bkkarthik

    bkkarthik

    Joined:
    Sep 8, 2017
    Posts:
    1
    ======================================================================================

    Thanks a ton Tautvydas-Zilys, Keep up the good work mate. I am sure this fixes the compatibility issues related to Unity 5.6.3p2 Vs Visual Studio 2017 on Windows 10. Tried and tested #100% working patch. Cheers!
     
  33. timokii

    timokii

    Joined:
    Aug 31, 2017
    Posts:
    1
    worked for unity 5,6,3. thanks :)
     
  34. huangjinhai

    huangjinhai

    Joined:
    Oct 21, 2018
    Posts:
    2
    “"D:\Unity\ModelExplorer\Completed\ModelExplorer\App\Unity\Tools\AssemblyConverter.exe" -platform=uap -bits=32 -configuration=Release -removeDebuggableAttribute=False -uwpsdk=10.0.17763.0 -path="." -path="D:\Unity\Editor\Data\PlaybackEngines\MetroSupport\Players\UAP\dotnet\x86\Release" -workingDir="D:\Unity\ModelExplorer\Completed\ModelExplorer\App\ModelExplorer\\" "@D:\Unity\ModelExplorer\Completed\ModelExplorer\App\ModelExplorer\AssemblyConverterArgs.txt"”exited 1。 ModelExplorer D:\Unity\ModelExplorer\Completed\ModelExplorer\App\ModelExplorer\ModelExplorer.csproj 467
    Is anybody solved this problem
     
  35. sebrk_hiq

    sebrk_hiq

    Joined:
    Jul 10, 2017
    Posts:
    23
    Worst issue description ever. Make some effort.
     
  36. k1018ic0105

    k1018ic0105

    Joined:
    Dec 9, 2018
    Posts:
    2
    I installed all of my next apps.
    But C# unchecked.
     

    Attached Files: