I have simple asp.net core project. I want to deploy it via TeamCity to IIS. The problem is that I can't setup ASPNETCORE_ENVIRONMENT when publishing the project. My goal is to use default behaviour to load appsettings files:
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true);
I use .csproj instead of project.json and Web.config's section related to configuration looks like:
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'prod-zone-a|AnyCPU' ">
<IntermediateOutputPath>obj\Debug\netcoreapp1.1</IntermediateOutputPath>
<DebugSymbols>true</DebugSymbols>
<Optimize>false</Optimize>
<DefineConstants>TRACE;DEBUG;NETCOREAPP1_1</DefineConstants>
</PropertyGroup>
Publish is executed like:
dotnet publish --configuration prod-zone-a --output <some-dir>
Also it's necessary to have several site on IIS published with different configurations: prod-zone-a, prod-zone-b, etc (corresponded appsettings.{env.EnvironmentName}.json looks different too)
How can I implement such idea? Or probably I should to throw this idea out and follow another way?
Update:
According to MS docs I've added separate build step to TeamCity (powershell command):
$Env:ASPNETCORE_ENVIRONMENT = "prod-zone-a"
but it doesn't work.