Dotnet核心应用程序在生产中找不到appsettings.json

我开发了一个在Dev Env中运行良好的Web Api + Angular JS应用程序。

当我在linux下部署它时,无法加载appsettings。*作为服务启动时(使用kestrel)。

当我手动启动,从它安装的文件夹,它运行良好,但如果我从根path尝试,使用完整path,它将失败相同的方式,在服务模式。

我应该创build一个sh脚本来启动它作为服务,或者我可以修改我的程序/启动类中的东西?

Program.cs:

public static void Main(string[] args) { var host = new WebHostBuilder() .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() .UseStartup<Startup>() .Build(); host.Run(); } 

Startup.cs

  public Startup(IHostingEnvironment env) { _env = env; var builder = new ConfigurationBuilder() .SetBasePath(env.ContentRootPath) .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true) .AddEnvironmentVariables(); Configuration = builder.Build(); }