Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Your project.json doesn't list 'win10' as a targeted runtime

I hate reposting, but I thought posting to the MSDN forum was the right thing to do since it looks there are not many people working on UWP apps with HTML/JavaScript, but, since I had no answers at all, I'm turning to the great SO community for help.

Problem:
I have a very simple UAP app in HTML/JavaScript that has a reference to a Windows Runtime Component which has a reference to a Class Library.

I need to project to run in either PCs and/or mobiles so I need to compile it with Any CPU. The problem is that whenever I want to compile my app I get the following error:

Your project.json doesn't list 'win10' as a targeted runtime. You should add '"win10": { }' inside your "runtimes" section in your project.json, and then re-run NuGet restore.

And If I do add the plain win10 entry under runtimes, I get many other errors. This is what my project.json looks like:

{
"dependencies": {
    "Microsoft.NETCore.UniversalWindowsPlatform": "5.0.0"
},
"frameworks": {
    "uap10.0": { }
},
"runtimes": {
    "win10-arm": { },
    "win10-arm-aot": { },
    "win10-x86": { },
    "win10-x86-aot": { },
    "win10-x64": { },
    "win10-x64-aot": { }
}
}

Also, there's a minimal repro here if anybody is interested in checking it out.

like image 849
sebagomez Avatar asked Jan 13 '16 13:01

sebagomez


2 Answers

AnyCPU is no longer a valid configuration for managed (C#/VB) UWP apps. This is because all managed code (exe or dlls) for a UWP app is compiled using .NET Native toolchain to build architecture specific binaries. So if you are using a managed WinRT component in your HTML/JS UWP app, you will also need to set the specific architecture in your app project based on the device you are deploying to i.e. x86 for Desktop, ARM for Phone device.

like image 88
Navit Saxena Avatar answered Nov 06 '22 13:11

Navit Saxena


I have a similar setup and the exact same problem. My current workaround is to set compiler to x86 when testing on the desktop, and changing to ARM when testing on mobile devices. Far from optimal, but if you figure out something better, I'd love to hear back.

According to this SO post, AnyCPU is not supported for UWP/C# apps.

In addition to making sure you test with .NET Native compilation, you may also notice that the AnyCPU build configuration has disappeared. With .NET Native brought into the mix, AnyCPU is no longer a valid build configuration because native compilation is architecture dependent. An additional consequence of this is that when you package your application, you should select all three architecture configurations (x86, x64 and ARM) to make sure your application is applicable to as many devices as possible.

Source: .NET Native – What it means for Universal Windows Platform (UWP) developers

like image 23
greentea Avatar answered Nov 06 '22 12:11

greentea