Severity Code Description Project File Line
Error CS1061 'IApplicationBuilder' does not contain a definition for 'UseStaticFiles' and no extension method 'UseStaticFiles' accepting a first argument of type 'IApplicationBuilder' could be found (are you missing a using directive or an assembly reference?) 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"
]
}
Best Answer
From your error message you can see that
UseStaticFiles
is available toDNX 4.5.1
framework but not toDNX Core 5.0
You should add the dependency to
Microsoft.AspNet.StaticFiles
not only todnx451
but also todnxcore50
in yourproject.json
. You can remove the depency in the"frameworks"
key and put it inside the"dependencies"
key to make it available for both frameworks