Compartilhar via


Why can't I deploy my UWP app with .Net Standard 2.0 to a Mobile device or emulator?

Several developers have been confused recently because they created new UWP apps using .Net Standard 2.0 and then weren't able to deploy the app to their Windows 10 Mobile devices.  Additionally, when trying to use the emulator, no debug targets show up in Visual Studio 2017.

UWP apps do not support .Net Standard 2.0 on Windows 10 Mobile

This behavior is expected.   Support for .Net Standard 2.0 was introduced in 1709 (build 16299) of Windows 10.   The current latest version of Windows 10 Mobile is 15254, which does not have the full API set of 1709.  As the above post explains:

That’s because .NET Standard 2.0 contains many APIs that require FCU to make them work in the context of the UWP execution environment, specifically AppContainer.

When a developer attempts to deploy from Visual Studio to a fully updated Windows 10 Mobile device, the IDE will give the following error:

 Error DEP3321: To deploy this application, your deployment target should be running Windows Universal Runtime version 10.0.16299.0 or higher. You currently are running version 10.0.15254.158. Please update your OS, or change your deployment target to a device with the appropriate version

At the time of this post, the only solutions are:

  • Reduce the app's minimum target version (which will have the effect of removing .Net Standard 2.0 support)
  • Switch the deployment target to a non-Mobile device.

Developers who want to keep updating features for their Windows 10 Mobile apps may need to avoid .Net Standard 2.0.  Within the application itself, a developer can utilize the Windows.Foundation.Metadata.ApiInformation class to ensure that a new API exists and is available for the target platform before calling it and reverting to older functionality if the new functionality isn't available.

Developers can also fork their builds into a .Net Framework 2.0 branch which targets newer functionality on Fall Creators Update systems with min version 16299 and a pre-.Net Framework 2.0 branch to run on devices (including Mobile) whose users haven't updated to 16299.

Xamarin

Current versions of Xamarin offer choices of a shared project (fine for Windows 10 Mobile) or a .Net Standard 2.0 project (replacing the previous PCL option). To target Windows 10 Mobile either use the shared project or open your .Net Standard project properties and downgrade it to .Net Standard 1.4. In either case, open your UWP project and set its Min version to 15254 or lower to run on Windows 10 Mobile.