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:
1>------ Build started: Project: AppTest, Configuration: Debug x86 ------
1> AppTest -> D:\AppTest\AppTest\bin\x86\Debug\AppTest.exe
1> UnityWSAPlayerDir "C:\Program Files\Unity\Editor\Data\PlaybackEngines\MetroSupport\".
1> UnityProjectDir "".
1> Copying unprocessed assemblies...
1> Running AssemblyConverter...
1> System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
1> at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
1> at UnityEditor.Scripting.Compilers.NuGetPackageResolver.Resolve()
1> at Unity.UWPAssemblyResolver..ctor(String projectLockFile, String desiredUWPSDKVersion)
1> at Unity.OperationContext.SetPlatform(Platform platform, String projectLockFile, String uwpSDK)
1> at Unity.ParseArgsStep.Execute()
1> at Unity.Step.Execute(OperationContext operationContext, IStepContext previousStepContext)
1> at Unity.Operation.Execute()
1> at Unity.Program.Main(String[] args)
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.
========== 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
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
Ok⌠think I finally found the VS2017 v15.0 downloads⌠they are available on my.visualstudio.com and you need to sign in to get access to the .exes:
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.
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.
@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).
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:
namespace FixVersion
{
class Program
{
static void Main(string[] args)
{
try
{
string content = string.Empty;
using (StreamReader reader = new StreamReader(AppDomain.CurrentDomain.BaseDirectory + @"\project.lock.json"))
{
content = reader.ReadToEnd();
content = content.Replace("UAP,Version=v10.0.10240", "UAP,Version=v10.0");
reader.Close();
}
using (StreamWriter writer = new StreamWriter(AppDomain.CurrentDomain.BaseDirectory + @"\project.lock.json"))
{
writer.Write(content);
writer.Close();
}
Console.WriteLine("DONE.");
}
catch(Exception ex)
{
Console.WriteLine("ERROR: " + ex.Message);
}
Console.WriteLine("Press any key to exit.");
Console.ReadKey();
}
}
}
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?
@DaTruAndi@AccentDave_1 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.
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.
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.