This answer was originally written for ASP.NET Core RC1. In RC2 ASP.NET Core moved from generic httpPlafrom handler to aspnetCore specific one. Note that step 3 depends on what version of ASP.NET Core you are using.
Turns out environment variables for ASP.NET Core projects can be set without having to set environment variables for user or having to create multiple commands entries.
- Go to your application in IIS and choose
Configuration Editor
.
- Select
Configuration Editor
- Choose
system.webServer/aspNetCore
(RC2 and RTM) or system.webServer/httpPlatform
(RC1) in Section
combobox
- Choose
Applicationhost.config ...
in From
combobox.
- Right click on
enviromentVariables
element, select 'environmentVariables' element
, then Edit Items
.
- Set your environment variables.
- Close the window and click Apply.
- Done
This way you do not have to create special users for your pool or create extra commands entries in project.json
.
Also, adding special commands for each environment breaks "build once, deploy many times" as you will have to call dnu publish
separately for each environment, instead of publish once and deploying resulting artifact many times.
Updated for RC2 and RTM, thanks to Mark G and tredder.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…