C# Azure Web App在Visual Studio更新后找不到appsettings.json
我刚刚在处理ASP.NET Core 1.1.1项目时更新了Visual Studio。在更新之前,我对Azure的持续交付运行得非常好。现在,我在部署后查看Web应用时收到一个错误。无法在根位置找到appsettings.json:C# Azure Web App在Visual Studio更新后找不到appsettings.json,c#,asp.net-core,C#,Asp.net Core,我刚刚在处理ASP.NET Core 1.1.1项目时更新了Visual Studio。在更新之前,我对Azure的持续交付运行得非常好。现在,我在部署后查看Web应用时收到一个错误。无法在根位置找到appsettings.json: The configuration file 'appsettings.json' was not found and is not optional. The physical path is 'D:\home\site\wwwroot\appsettings.
The configuration file 'appsettings.json' was not found and is not optional. The physical path is 'D:\home\site\wwwroot\appsettings.json'.
它现在正在wwwroot文件夹中查找该文件。这不是它在更新之前查找的基本路径。我没有更新到ASP.NET Core 2.0
我的configurationbuilder如下所示:
var builder = new ConfigurationBuilder()
.SetBasePath(env.ContentRootPath)
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true);
appsettings.json文件是否应该被移动,或者这里发生了什么事?在Azure中,
wwwroot
也是应用程序的“基本路径”的名称,所有DLL和app.config都放置在该路径中。站点的“wwwroot”(包含图像、脚本和其他内容)是子文件夹,如D:\home\site\wwwroot\wwwroot
。你可以很容易地检查这个使用
更新后,请仔细检查对文件的更改,尝试在本地运行-可能是.csproj文件中发生了更改,并且不再发布applications.json