我无法弄清楚如何在我的UWP目标版本中生成项目(类库),它定义了“netstandard1.3”和“uap10.0”目标。错误UWP目标中名称空间“Windows”中不存在类型或名称空间名称“Networking”,如何修复多目标项目中的project.json
如果我在Visual Studio 2015向导中将其创建为UWP类型的单独项目,但我更愿意将其作为单个多目标项目中的目标之一构建,我已成功构建UWP项目(其中I然后再添加更多目标)。
{
"version": "1.0.0-*",
"frameworks": {
"netstandard1.3": {
"dependencies": {
"NETStandard.Library": "1.6.0",
"Microsoft.Win32.Registry": "4.0.0",
"System.Collections.NonGeneric": "4.0.1",
"System.Collections.Specialized": "4.0.1",
"System.Net.NameResolution": "4.0.0",
"System.Net.NetworkInformation": "4.1.0",
"System.Net.Requests": "4.0.11",
"System.Net.Security": "4.0.0",
"System.Reflection": "4.1.0",
"System.Runtime.Extensions": "4.1.0",
"System.Runtime.InteropServices.RuntimeInformation": "4.0.0",
"System.Security.Cryptography.Algorithms": "4.2.0",
"System.Security.Cryptography.Pkcs": "4.0.0",
"System.Security.Principal.Windows": "4.0.0",
"System.Threading.Thread": "4.0.0",
"System.Xml.XmlDocument": "4.0.1",
"System.Globalization.Extensions": "4.0.1"
}
},
"uap10.0": {
"frameworkAssemblies": {
"System.Runtime": "",
"System.Runtime.Extensions": "",
"System.Windows": ""
},
"dependencies": {
"Microsoft.NETCore.UniversalWindowsPlatform": "5.2.2",
"NETStandard.Library": "1.6.0",
"Microsoft.Win32.Registry": "4.0.0",
"System.Collections.NonGeneric": "4.0.1",
"System.Collections.Specialized": "4.0.1",
"System.Net.NameResolution": "4.0.0",
"System.Net.NetworkInformation": "4.1.0",
"System.Net.Requests": "4.0.11",
"System.Net.Security": "4.0.0",
"System.Reflection": "4.1.0",
"System.Runtime.Extensions": "4.1.0",
"System.Runtime.InteropServices.RuntimeInformation": "4.0.0",
"System.Security.Cryptography.Algorithms": "4.2.0",
"System.Security.Cryptography.Pkcs": "4.0.0",
"System.Security.Principal.Windows": "4.0.0",
"System.Threading.Thread": "4.0.0",
"System.Xml.XmlDocument": "4.0.1",
"System.Globalization.Extensions": "4.0.1"
},
"buildOptions": { "define": [ "WINDOWS_UWP" ] }
}
}
}
}
我无法找到任何简单的例子,如何编写UWP库(理想情况下,对于UWP和非UWP多目标项目一次)project.json。所以我主要使用试验和错误(通过添加这个或那个部分并将它们移到project.json中),但没有成功。
例如,它似乎frameworkAssemblies System.Runtime,System.Runtime.Extensions,System.Windows无效的UWP,但我不能猜测哪些应该在那里。如果这部分不在那里,它也不会构建。我老实说花了几天的时间阅读project.json规范和它的指令之间的所有差异,但它仍然很模糊。
netstandard1.3 target builds没有问题。实际上,我很高兴将UWP作为一个单独的项目来构建,但是当我想添加win8-wpa81(我努力支持尽可能多的平台来支持我的图书馆)时,这并没有扩展,这就是为什么我决定迁移到具有多目标项目的单个项目.json
我对UWP选择是类库(便携式适用于iOS,等等)。您的链接没有提到Windows.Networking。同样,在将UWP项目作为单独项目构建时,我没有任何问题。您正在描述如何创建UWP项目。我已经完成了这个工作。我想知道是否有可能将UWP目标“合并”为.NET核心类库,除了netstandard1.3目标之外,它还会有UWP目标。是否有可能建立一个单独的项目,可以建立很多差异。类库的版本,包括.NET Core,UWP,Win8等? – Alex
@Alex我认为这是不可能的。 – 2017-02-01 02:14:07