我正在尝试在 OS X 上创建使用 ASP.NET 5 运行的第一个示例应用程序。但是我只是无法弄清楚 project.json 依赖项是如何工作的。我用 yeoman 生成了 Web Api 应用程序,在我尝试使用 WebClient 之前一切正常。根据 dnvm list 我正在运行:
* 1.0.0-rc1-update2 mono linux/osx
虽然恢复包进展顺利,但项目在构建步骤中失败了。这是我的 project.json 文件:
{
"version": "1.0.0-*",
"compilationOptions": {
"emitEntryPoint": true
},
"tooling": {
"defaultNamespace": "LocationService"
},
"dependencies": {
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
"Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
"Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
"Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
"Microsoft.Extensions.Configuration.FileProviderExtensions": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-final"
},
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel"
},
"frameworks": {
"dnx451": {
"dependencies": {
"System.Web.Http": "4.0.0"
}
},
"dnxcore50": {
}
},
"exclude": [
"wwwroot",
"node_modules",
"bower_components"
],
"publishExclude": [
"**.user",
"**.vspscc"
]
}
并且项目在构建时失败,参考未解决:
LocationService/Controllers/ValuesController.cs(32,40):
DNXCore,Version=v5.0 error CS0246: The type or namespace name
'WebClient' could not be found (are you missing a using directive or an
assembly reference?)
我尝试在 dnxcore50 和 dnx451 下添加依赖项。Dmvm 告诉我,我可以使用 coreclr x64,但在我的情况下它似乎不起作用 - 在构建过程中最终会出现大量未解析的引用。