用 dotnet build 命令编译 ASP.NET Core RC2 站点时出现如下的错误:
Startup.cs(24,6): error CS1061: 'ConfigurationBuilder' does not contain a definition for 'SetBasePath' and no extension method 'SetBasePath' accepting a first argument of type 'ConfigurationBuilder' could be found (are you missing a using directive or an assembly reference?)
Startup.cs 中的对应代码如下:
public Startup(IHostingEnvironment hostingEnv) { IConfigurationBuilder builder = new ConfigurationBuilder() .SetBasePath(hostingEnv.ContentRootPath) .AddJsonFile("config.json", false); Configuration = builder.Build(); }
在project.json中添加如下的配置:
"Microsoft.Extensions.Configuration.FileExtensions": "1.0.0-*"