Running locally via Visual Studio and JetBrains Rider and managing the ASPNETCORE_ENVIRONMENT variable has been challenging.  Changing and setting ASPNETCORE_ENVIRONMENT within launchSettings.json and/or within Project Properties impacts the web.{envrionment}.config files.  Without the appropriate configuration within the publish steps the site was being deployed with incorrect settings and it was time consuming to track it back to the best approach.  So for now I have a pipeline build process setup for each AppService ‘slot’ setting different BuildConfiguration within each to ensure the most appropriate web.config is deployed.

This is a .net core asp.net web application so why the web.config? It appears that locally during IIS Express/IIS there is still a dependency on this web.config to identify the hosting model (inprocess) and reference to the exe that would be run.  This is of course when deploying to Windows infrastructure.

Project Properties – Environment variables

image

My launchSettings.json – you can see I can modify before running how IIS or IIS Express identifies the environment variable

image

The resultant/related web.configs looks like the following for Development and Staging environments.

web.config
image

web.Staging.config (you can see the addition of the xdt:Transform=”Replace” attribute which informs publish that when building for Staging to replace this variable within web.config with this value)
image

By default the build process on Azure DevOps – Pipelines was ignoring any file transformation requirements.  In order to establish File Transformation on publish notice the –configuration $(BuildConfiguration)
image

and the respective variable that is used during publish to identify the appropriate configuration to use (development/staging etc.)
image

After the build and using App Service Editor my web.config was successfully transformed

image

Comments


Comments are closed

About Us

Web/Mobile Solutions

Our Contacts

Cincinnati, OH 45069