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

sebagomez picture sebagomez · Jan 13, 2016 · Viewed 7.9k times · Source

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.

Answer

Navit Saxena picture Navit Saxena · Mar 25, 2016

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.