简体   繁体   中英

Unable to add UWP target from CSProj file

I've added uap10.0 to the target frameworks list in the CSProj file (Net Core project) so that I can reference this library from a UWP project.

As follows:-

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFrameworks>netcoreapp1.1;net462;uap10.0;xamarin.ios10;MonoAndroid70</TargetFrameworks>
  </PropertyGroup>

</Project>

But when building I get the following error message:-

C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.TargetFrameworkInference.targets(84,5): error : Cannot infer TargetFrameworkIdentifier and/or TargetFrameworkVersion from TargetFramework='uap10.0'. They must be specified explicitly.
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(1111,5): error MSB3644: The reference assemblies for framework ".NETFramework,Version=v10.0" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend.

What I have failed to do?

Thanks.

You can target .NET Standard 1.4 which is the first version to support uap10.0, by adding the following in your csproj:

<PropertyGroup>
    <TargetFrameworks>netstandard1.4;net462;netcoreapp1.0</TargetFrameworks>
</PropertyGroup>

It also looks like the order of target frameworks is important as well. According to this issue , netstandard reference should be first. In the mentioned link the answer to the issue was:

I still have this issue using VS2019, and referencing P2P from UWP(targeting 17763) a cross-platform library. Restarting VS and putting netstandard2.0 as the first target fixed the issue

<TargetFrameworks>netstandard2.0;net462</TargetFrameworks>

It helped me, hopefully it helps someone else.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM