Unity 5.6 .NET framework problems in Visual Studio

When I compile the default C# script for Unity 5.6 in Visual Studio 2015 or 2017, I get warnings that the references for nunit.framework and UnityEngine.TestRunner couldn’t be resolved because they both have an indirect dependency on a System.Web assembly that’s not available in .NET 3.5, the default targeted framework for Unity 5.6 projects. The nunit.framework and UnityEngine.TestRunner assemblies were installed with Unity 5.6, and the references are added by default in new Unity 5.6 C# solutions (in both Visual Studio and MonoDevelop).

Interestingly, these warning don’t appear in MonoDevelop, so I understand that one solution would be “don’t use Visual Studio, use MonoDevelop”, but I need some of the higher-end Visual Studio capabilities that aren’t available in MonoDevelop.

I’m actually getting ready to start exploring using NUnit and the Unity test runner to test my games, so removing those references from my Visual Studio project to get rid of the warnings isn’t an option either.

Any suggestions on how to resolve this?

Both of the warnings will go away if you change your project’s API Compatibility Level to “.NET 2.0”. You’ll need to relaunch Visual Studio to see the results.

You’ll find that setting in the “Other Settings” section of Player Settings, which you can access via Edit | Project Settings | Player.

This is merely a workaround. Ideally, the default “.NET 2.0 Subset” option would also work without producing the warnings.