问题描述
我有几个WebDeploy发布配置文件,这些配置文件将.NET Core Web项目部署到各个位置(Dev,QA,IIS上的Stage).为了使应用程序知道它在哪里运行,我需要设置ASPNETCORE_ENVIRONMENT环境变量.
是否可以将ASPNETCORE_ENVIRONMENT环境变量设置为发布应用程序的一部分?
P.S.
第2步:
现在选择 system.webserver/asp.netcore ,然后在其他下拉列表中选择下图所示的 applicationHost.config .
第3步:
现在选择 enviromentVariable 并输入值.
希望对您有帮助.
I have several WebDeploy publish profiles that deploy my .NET Core web project to various places (Dev, QA, Stage on IIS). For the application to know where it's running, I need to set the ASPNETCORE_ENVIRONMENT environment variable.
Is it possible to set the ASPNETCORE_ENVIRONMENT environment variable as a part of publishing the application?
P.S. This question doesn't solve anything for me because it shows how to achieve it manually. I would like it to be automatic as a part of deploy a publish profile.
You can Just Update your webconfig file with below text in section.
<configuration>
<system.webServer>
<aspNetCore .....>
<environmentVariables>
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />
</environmentVariables>
</aspNetCore>
</system.webServer>
</configuration>
Or you can follow below step after hosting your application in IIS.
Step 1 :Click on configuration editor as shown in below image
Step 2 :
now select system.webserver/asp.netcore and in other dropdown select applicationHost.config shown in below image.
Step 3 :
Now select enviromentVariable and enter value.
I hope it may help you.
这篇关于发布期间如何设置ASPNETCORE_ENVIRONMENT?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!