不能使用" Microsoft.AspNet.StaticFiles":" 1.0.0-rc1-final"

时间:2016-02-22 16:02:49

标签: asp.net asp.net-core asp.net-core-mvc

Screenshot of Solution explorer with errors

就在最近,我一直在尝试新的asp.net功能并遇到了这个错误。我尝试使用app.UseStaticFiles并添加了依赖项,但由于某种原因它似乎没有编译?

错误是:

Screenshot of errors

Project.json包含:

{
  "version": "1.0.0-*",
  "compilationOptions": {
    "emitEntryPoint": true
  },

  "dependencies": {

    "Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
    "Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
    "Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final"
  },

  "commands": {

    "web": "Microsoft.AspNet.Server.Kestrel"
  },

  "frameworks": {

    "dnx451": { },
    "dnxcore50": { }
  },

  "exclude": [

    "wwwroot",
    "node_modules"
  ],
  "publishExclude": [

    "**.user",
    "**.vspscc"
  ]
}

输出:

1>C:\Users\sachinl\Desktop\TheWebApp\src\TheWebApp\project.lock.json(1-1): DNX 4.5.1 error NU1006: Dependencies in project.json were modified. Please run "dnu restore" to generate a new lock file.
1>C:\Users\sachinl\Desktop\TheWebApp\src\TheWebApp\project.json(10,37,10,37): DNX 4.5.1 error NU1001: The dependency Microsoft.AspNet.StaticFiles >= 1.0.0-rc1-final could not be resolved.
1>C:\Users\sachinl\Desktop\TheWebApp\src\TheWebApp\project.lock.json(1-1): DNX 4.5.1 error NU1006: Dependencies in project.json were modified. Please run "dnu restore" to generate a new lock file.
1>C:\Users\sachinl\Desktop\TheWebApp\src\TheWebApp\project.json(10,37,10,37): DNX 4.5.1 error NU1001: The dependency Microsoft.AspNet.StaticFiles >= 1.0.0-rc1-final could not be resolved.
1>C:\Users\sachinl\Desktop\TheWebApp\src\TheWebApp\Startup.cs(23,17,23,31): DNX 4.5.1 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?)
1>C:\Users\sachinl\Desktop\TheWebApp\src\TheWebApp\project.lock.json(1-1): DNX Core 5.0 error NU1006: Dependencies in project.json were modified. Please run "dnu restore" to generate a new lock file.
1>C:\Users\sachinl\Desktop\TheWebApp\src\TheWebApp\project.json(10,37,10,37): DNX Core 5.0 error NU1001: The dependency Microsoft.AspNet.StaticFiles >= 1.0.0-rc1-final could not be resolved.
1>C:\Users\sachinl\Desktop\TheWebApp\src\TheWebApp\project.lock.json(1-1): DNX Core 5.0 error NU1006: Dependencies in project.json were modified. Please run "dnu restore" to generate a new lock file.
1>C:\Users\sachinl\Desktop\TheWebApp\src\TheWebApp\project.json(10,37,10,37): DNX Core 5.0 error NU1001: The dependency Microsoft.AspNet.StaticFiles >= 1.0.0-rc1-final could not be resolved.
1>C:\Users\sachinl\Desktop\TheWebApp\src\TheWebApp\Startup.cs(23,17,23,31): DNX Core 5.0 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?)

1 个答案:

答案 0 :(得分:0)

在dnu恢复期间

could not be resolved通常意味着,它无法在您配置的nuget上找到NuGet包。

在Visual Studio中,转到Tools/Nuget Package Manager/Package Manager Settings并检查其中配置的内容。

至少应该有一个指向nuget.org的条目:https://www.nuget.org/api/v2

如果有,那么您可能在解决方案级别上有一个nuget.config。检查解决方案文件夹或nuget.config文件夹中是否有\.Nuget文件。