Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-core/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net core 在生产环境中发布并运行ASP.NET Core 1.0应用程序_Asp.net Core_Asp.net Core 1.0 - Fatal编程技术网

Asp.net core 在生产环境中发布并运行ASP.NET Core 1.0应用程序

Asp.net core 在生产环境中发布并运行ASP.NET Core 1.0应用程序,asp.net-core,asp.net-core-1.0,Asp.net Core,Asp.net Core 1.0,在ASPNETCORE 1.0应用程序上,我在启动时具有以下功能: public Startup(IHostingEnvironment hostingEnvironment) { ConfigurationBuilder builder = new ConfigurationBuilder(); builder .SetBasePath(hostingEnvironment.ContentRootPath) .AddJsonFile("settings.json",

在ASPNETCORE 1.0应用程序上,我在启动时具有以下功能:

public Startup(IHostingEnvironment hostingEnvironment) {

  ConfigurationBuilder builder = new ConfigurationBuilder();

  builder
    .SetBasePath(hostingEnvironment.ContentRootPath)
    .AddJsonFile("settings.json", false, true)
    .AddJsonFile($"settings.{hostingEnvironment.EnvironmentName}.json", false, true);
  builder.AddEnvironmentVariables();

  Configuration = builder.Build();

}
我的项目中有2个设置文件:

settings.json
settings.production.json
我使用命令行发布了该项目:

set ASPNETCORE_ENVIRONMENT=production
dotnet publish --configuration Release
发布的文件包括
settings.json
,但不包括
settings.production.json
。而
settings.json
确实包含仅在
settings.production.json
中的属性。它们不应该在发布时合并吗

除此之外,当我将文件复制到服务器时,如何确保应用程序在生产模式下运行


我需要在
Web.config
上执行任何操作吗?

您需要更新
project.json
以将
设置.production.json
文件添加到
publishOptions
include
部分:

{
  "publishOptions": {
    "include": [
      "wwwroot",
      "Views",
      "Areas/**/Views",
      "settings.json",
      "settings.production.json",
      "web.config"
    ]
  }
}

好的,当服务器上有应用程序时,如何“告诉它”在生产环境中运行?您应该在将在生产环境中运行应用程序的服务器上设置环境变量
ASPNETCORE\u environment=production
。有关更多详细信息,请参阅本文讨论的是环境变量,而不是在服务器中设置它们以及各种选项。然后,我发现: