Building Android Xamarin.Forms Project on Windows Fails

Tony Pitman 76 Reputation points
2021-10-21T19:52:18.057+00:00

I have a solution based on Xamarin Forms. I have included a library called Plugin.BluetoothLE. This project has several platform folders that target the different platforms. This includes Android, iOS and UWP.

When I build the Android target project on my Mac using Visual Studio 2019 for Mac everything builds just fine.

When I try to build the same project on my Windows 10 computer with Visual Studio 2019 it fails. Here is the error I am getting:

1>C:\dev\Software_mobile\Components\bluetoothle\Plugin.BluetoothLE\Extensions_Device.cs(169,13,171,28): error CS0012: The type 'IAsyncOperation<>' is defined in an assembly that is not referenced. You must add a reference to assembly 'Windows.Foundation.FoundationContract, Version=4.0.0.0, Culture=neutral, PublicKeyToken=null, ContentType=WindowsRuntime'.

Why is this library trying to include something from Windows? It should be cross platform when I build for Android and builds fine on MacOS VS2019.

How can I get this to build on Windows VS2019?

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,296 questions
{count} votes