严重级代码说明项目文件行 错误CS1061' IApplicationBuilder'不包含' UseStaticFiles'的定义没有扩展方法' UseStaticFiles'接受类型' IApplicationBuilder'的第一个参数。可以找到(您是否缺少using指令或程序集引用?)MyWorld.DNX Core 5.0 C:\ Projects \ MyWorld \ src \ MyWorld \ Startup.cs 21
Project.json
{
"webroot": "wwwroot",
"version": "1.0.0-*",
"dependencies": {
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-beta8",
"Microsoft.AspNet.Server.Kestrel": "1.0.0-beta8"
},
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel"
},
"frameworks": {
"dnx451": {
"dependencies": {
"Microsoft.AspNet.StaticFiles": "1.0.0-beta8"
}
},
"dnxcore50": { }
},
"exclude": [
"wwwroot",
"node_modules"
],
"publishExclude": [
"**.user",
"**.vspscc"
]
}
答案 0 :(得分:9)
从错误消息中,您可以看到UseStaticFiles
框架可以使用DNX 4.5.1
,但DNX Core 5.0
Microsoft.AspNet.StaticFiles
您应该将依赖关系dnx451
添加到dnxcore50
,但也应添加到project.json
的{{1}}。您可以删除"frameworks"
密钥中的依赖项,并将其放在"dependencies"
密钥中,以使其可用于两个框架
{
...
"dependencies": {
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-beta8",
"Microsoft.AspNet.Server.Kestrel": "1.0.0-beta8",
"Microsoft.AspNet.StaticFiles": "1.0.0-beta8",
},
...
"frameworks": {
"dnx451": { },
"dnxcore50": { }
}
...
}