【问题标题】:Azure Web App fails to locate appsettings.json after Visual Studio updateVisual Studio 更新后 Azure Web App 无法找到 appsettings.json
【发布时间】:2017-08-16 18:52:20
【问题描述】:

我刚刚在处理 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.json'.

它现在正在 wwwroot 文件夹中寻找文件。这不是它在更新之前寻找的基本路径。我没有更新到 ASP.NET Core 2.0。

我的配置生成器如下所示:

var builder = new ConfigurationBuilder()
                .SetBasePath(env.ContentRootPath)
                .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
                .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true);

appsettings.json 文件应该被移动还是这里发生了什么?

【问题讨论】:

    标签: c# asp.net-core


    【解决方案1】:

    在 Azure 中,wwwroot 也是放置所有 dll 和 app.config 的应用的“基本路径”的名称。您站点的“wwwroot”(包含图像、脚本和其他)是子文件夹,例如 D:\home\site\wwwroot\wwwroot。您可以使用Kudu 轻松检查。

    更新后仔细检查对文件的更改,尝试在本地运行 dotnet publish - 可能在您的 .csproj 文件中发生了更改,applications.json 不再发布。

    【讨论】:

      猜你喜欢
      • 2023-01-27
      • 1970-01-01
      • 1970-01-01
      • 2016-07-27
      • 2020-08-09
      • 1970-01-01
      • 2021-11-06
      • 1970-01-01
      • 2017-02-12
      相关资源
      最近更新 更多