问题
I recently created a blank UWP application in Visual Studio 2015, and then tried to add a nuget package to that application. The package installation failed and resulted in the following messasges in the output window...
System.Reflection.Emit.ILGeneration 4.0.1 provides a compile-time reference assembly for System.Reflection.Emit.ILGeneration on UAP,Version=v10.0, but there is no run-time assembly compatible with win10-arm-aot.
One or more packages are incompatible with UAP,Version=v10.0 (win10-arm-aot).
System.Reflection.Emit.ILGeneration 4.0.1 provides a compile-time reference assembly for System.Reflection.Emit.ILGeneration on UAP,Version=v10.0, but there is no run-time assembly compatible with win10-x64-aot.
One or more packages are incompatible with UAP,Version=v10.0 (win10-x64-aot).
System.Reflection.Emit.ILGeneration 4.0.1 provides a compile-time reference assembly for System.Reflection.Emit.ILGeneration on UAP,Version=v10.0, but there is no run-time assembly compatible with win10-x86-aot.
One or more packages are incompatible with UAP,Version=v10.0 (win10-x86-aot).
Looking around, I have found references to the "runtimes" within the "project.json"; (mine looks like this)...
{
"dependencies": {
"Microsoft.NETCore.UniversalWindowsPlatform": "5.1.0"
},
"frameworks": {
"uap10.0": {}
},
"runtimes": {
"win10-arm": {},
"win10-arm-aot": {},
"win10-x86": {},
"win10-x86-aot": {},
"win10-x64": {},
"win10-x64-aot": {}
}
}
My question is this: what is the difference between each "runtime" and the equivalent runtime with "-aot" appended?
I have seen some posts that indicate I can delete these runtimes if I want to use a nuget package that does not support them, but I would prefer to only delete them knowing what they are.
Note: I do not know if this makes any difference, but the UWP application that I am building is expected to only ever be side-loaded (it is a line of business application). It may however eventually need to be distributed via the Windows Business Store in order to ease updates etc.
Thanks.
回答1:
Runtime is a general term that refers to any library, framework, or platform that your code runs on. The win10-arm and win10-arm-aot runtimes are different platforms. Here is a Wikipedia: Runtime system. Besides, as per Wikipedia Ahead-of-time (AOT):
Ahead-of-time (AOT) compilation is the act of compiling a high-level programming language such as C or C++, or an intermediate language such as Java bytecode or .NET Common Intermediate Language (CIL) code, into a native (system-dependent) machine code with the intention of executing the resulting binary file natively. Some programming languages with a managed code runtime that can be compiled to an intermediate language, take advantage of just-in-time (JIT)
So I agree with Hans Passant, the AOT compiler is incompatible with System.Reflection.Emit.ILGeneration package. So you can delete these aot runtimes if you want to use this package.
回答2:
I found the solution to my case. I had several projects in my solution and all of them were using
Microsoft.NETCore.UniversalWindowsPlatform V 5.2.3
except for one project. It was using
Microsoft.NETCore.UniversalWindowsPlatform V 5.0.0
When I update the 5.0.0 to 5.2.3 all the errors went away.
NOTE: You do not need to remove aot tags from the JSON files.
来源:https://stackoverflow.com/questions/42008460/universal-windows-platform-uap-what-is-aot