我尝试在单声道下运行asp.Net 5 mvc。对于第一步,我尝试从 yo 运行应用程序模板 我的步骤是:
yo aspnet
< - 选择名为MyWeb的WebApplication
cd MyWeb
kpm restore --source https://www.myget.org/F/aspnetvnext/api/v2/
< - 完成没有错误
kpm build
在该命令之后我得到以下错误:
/home/dev/WORKSPACE/MyWeb/MyWeb/Startup.cs(29,16):错误CS0246:类型或命名空间名称' IConfiguration'找不到(你错过了使用指令或程序集引用吗?) /home/dev/WORKSPACE/MyWeb/MyWeb/Startup.cs(32,39):错误CS0246:类型或命名空间名称' IServiceCollection'找不到(你错过了使用指令或程序集引用吗?) /home/dev/WORKSPACE/MyWeb/MyWeb/Startup.cs(59,56):错误CS0246:类型或命名空间名称' IHostingEnvironment'找不到(你错过了使用指令或程序集引用吗?) /home/dev/WORKSPACE/MyWeb/MyWeb/Startup.cs(59,81):错误CS0246:类型或命名空间名称' ILoggerFactory'找不到(你错过了使用指令或程序集引用吗?) /home/dev/WORKSPACE/MyWeb/MyWeb/Startup.cs(21,24):错误CS0246:类型或命名空间名称' IHostingEnvironment'找不到(你错过了使用指令或程序集引用吗?) /home/dev/WORKSPACE/MyWeb/MyWeb/Models/IdentityModels.cs(21,37):错误CS0246:类型或命名空间名称' IHostingEnvironment'找不到(你错过了使用指令或程序集引用吗?) /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出了问题但是用尽了如何解决这个问题。我希望有人能给我一个暗示,指出我正确的方向!
非常感谢您的阅读! 关心亚历克斯
答案 0 :(得分:1)
不确定,但在我的VisualStudio MyGet地址是" https://www.myget.org/F/aspnetvnext/"。尝试使用kpm恢复。
另外,在VS CTP5-> CTP6更新后得到相同的错误,从beta2-> beta3恢复包有帮助,所以包版本错误似乎是错误的。
添加了: 如果您遇到迁移错误,请将其替换为:
/*
using Microsoft.Data.Entity.Migrations;
using Microsoft.Data.Entity.Migrations.Builders;
using Microsoft.Data.Entity.Migrations.Infrastructure;
*/
using Microsoft.Data.Entity.Relational.Migrations;
using Microsoft.Data.Entity.Relational.Migrations.Builders;
using Microsoft.Data.Entity.Relational.Migrations.Infrastructure;