Reputation: 3361
I'm trying to create some unit tests for my cross-platform (Android/iOS/UWP) Xamarin C# project. My target for the UWP version of the app is a Windows Surface tablet. Here's what I did.
In the NuGet Package Manager, select xunit v2.2.0 and click install. Get this error:
Could not install package 'xunit.assert 2.2.0'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.5,Profile=Profile259', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.
Check the properties for my project, see that it has a lot of targets: .NET Framework 4.5, ASP.NET Core 1.0, Windows 8, Windows Phone 3.1, Windows Phone Silverlight 8, Xamarin.Android, Xamarin.iOS, Xamarin.iOS (Classic), and Xamarin.Mac. Hit the "Change" button.
Uncheck Xamarin.Mac, .NET Framework 4.5, and ASP.NET Core 1.0. Add check for Windows Universal 10.0. Click OK. Get error:
The project's targets cannot be changed. The selected targets require the project to opt-into NuGet 3.0 support, however Visual Studio cannot automatically do this for you. Please uninstall all NuGet packages and try again.
OK fine, back to NuGet Package Manager, uninstall Xamarin.Forms.
Get new error:
Could not install package 'System.Runtime.InteropServices.RuntimeInformation 4.0.0'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.6,Profile=Profile44', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.
Go back to the main project's properties, it still says it's targeting .NET Framework 4.5.1, not 4.6.
So how do I get xunit to work with Xamarin in Visual Studio 2017?
Upvotes: 1
Views: 612
Reputation: 3361
One solution (maybe someone has a better one): Install xunit version 2.1.0 instead of 2.2.0. For some reason it works better.
Upvotes: 1