我尝试让一个在单声道下运行的 asp.Net 5 mvc。对于第一步,我尝试从yo 我的步骤运行应用程序模板:
yo aspnet
<- 选择名称为 MyWeb 的 WebApplication
cd MyWeb
kpm restore --source https://www.myget.org/F/aspnetvnext/api/v2/
<- 完成没有错误
kpm build
在该命令之后,我收到以下错误:
错误 CS0246:找不到类型或命名空间名称“IHostingEnvironment”(您是否缺少 using 指令或程序集引用?)/home/dev/WORKSPACE/MyWeb/MyWeb/Models/IdentityModels.cs(21,37):错误 CS0246:找不到类型或命名空间名称“IHostingEnvironment”(您是否缺少 using 指令或程序集引用?) /home/dev/WORKSPACE/MyWeb/MyWeb/Startup.cs(24,29):错误 CS0012 :类型“IConfigurationSourceContainer”是在未引用的程序集中定义的。您必须添加对程序集“Microsoft.Framework.ConfigurationModel.IConfigurationSourceContainer, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null”的引用。/home/dev/WORKSPACE/MyWeb/MyWeb/Startup.cs(40,17):错误 CS0012:类型“IServiceCollection” 在未引用的程序集中定义。您必须添加对程序集“Microsoft.Framework.DependencyInjection.IServiceCollection, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null”的引用。/home/dev/WORKSPACE/MyWeb/MyWeb/Startup.cs(46,13):错误 CS0012:类型“IServiceCollection”在未引用的程序集中定义。您必须添加对程序集“Microsoft.Framework.DependencyInjection.IServiceCollection, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null”的引用。/home/dev/WORKSPACE/MyWeb/MyWeb/Startup.cs(50,13):错误 CS0012:类型“IServiceCollection”在未引用的程序集中定义。您必须添加对程序集“Microsoft.Framework.DependencyInjection.IServiceCollection, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null”的引用。/home/dev/WORKSPACE/MyWeb/MyWeb/Startup.cs(63,13):错误 CS0012:类型“ILoggerFactory”在未引用的程序集中定义。您必须添加对程序集“Microsoft.Framework.Logging.ILoggerFactory, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null”的引用。
这是我的 project.json:
{
/* Click to learn more about project.json http://go.microsoft.com/fwlink/?LinkID=517074 */
"webroot": "wwwroot",
"version": "1.0.0-*",
"dependencies": {
"EntityFramework.SqlServer": "7.0.0-beta3",
"EntityFramework.Commands": "7.0.0-beta3",
"Microsoft.AspNet.Mvc": "6.0.0-beta3",
/* "Microsoft.AspNet.Mvc.WebApiCompatShim": "6.0.0-beta3", */
"Microsoft.AspNet.Diagnostics": "1.0.0-beta3",
"Microsoft.AspNet.Diagnostics.Entity": "7.0.0-beta3",
"Microsoft.AspNet.Identity.EntityFramework": "3.0.0-beta3",
"Microsoft.AspNet.Security.Cookies": "1.0.0-beta3",
"Microsoft.AspNet.Server.IIS": "1.0.0-beta3",
"Microsoft.AspNet.Server.WebListener": "1.0.0-beta3",
"Microsoft.AspNet.StaticFiles": "1.0.0-beta3",
"Microsoft.Framework.ConfigurationModel.Json": "1.0.0-beta3",
"Microsoft.Framework.CodeGenerators.Mvc": "1.0.0-beta3",
"Microsoft.Framework.Logging": "1.0.0-beta3",
"Microsoft.Framework.Logging.Console": "1.0.0-beta3",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-beta3",
/* Modifications for Mono Support*/
"EntityFramework.InMemory": "7.0.0-beta3",
"Kestrel": "1.0.0-beta3"
},
"commands": {
/* Change the port number when you are self hosting this application */
"web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:5001",
"kestrel": "Microsoft.AspNet.Hosting --server Kestrel --server.urls http://localhost:5004",
"gen": "Microsoft.Framework.CodeGeneration",
"ef": "EntityFramework.Commands"
},
"frameworks": {
"aspnet50": {},
"aspnetcore50": {}
},
"exclude": [
"wwwroot",
"node_modules",
"bower_components"
],
"bundleExclude": [
"node_modules",
"bower_components",
"**.kproj",
"**.user",
"**.vspscc"
],
"scripts": {
"postrestore": ["npm install"],
"prepare": ["grunt bower:install"]
}
}
使用的版本是:Mono JIT 编译器版本 3.12.0(tarball Sat Feb 7 19:13:43 UTC 2015)KRE:1.0.0-beta4-11166
似乎 Microsoft.Framework.ConfigurationModel 出了点问题,但没有办法解决这个问题。我希望有人能给我一个提示,为我指明正确的方向!
非常感谢阅读!问候亚历克斯