我为我的 ASP.NET Core 应用程序设置了三个配置文件。从 Visual Studio 中我选择一个配置文件然后发布(到本地文件)我在指定的文件夹中获取已发布的应用程序(由配置文件中的元素指定。我遇到的问题是我需要 web.config 看起来像:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\app.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout">
<environmentVariables>
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Docker" />
</environmentVariables>
</aspNetCore>
</system.webServer>
</configuration>
相反,我得到了
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\app.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
</system.webServer>
</configuration>
我不知道如何让部分自动插入 web.confg。理想情况下,我希望根据我选择发布应用程序的配置文件来设置 ASPNETCORE_ENVIRONMENT。
谢谢。