Build environment

See which environment name build-time code runs under, and how to build production data from a Debug build.

On this page
bash
ASPNETCORE_ENVIRONMENT=Production dotnet build

Build-time code runs under one environment name. That covers processors, loaders and appsettings.{Environment}.json. Bevel picks the first of these that is set:

  1. ASPNETCORE_ENVIRONMENT
  2. DOTNET_ENVIRONMENT
  3. The BevelEnvironment MSBuild property (Development for Debug builds, else Production)

Changing it reruns the data step

Bevel resolves the name in MSBuild once, passes it to the data step, and treats it as an input. Changing it (for example ASPNETCORE_ENVIRONMENT=Staging dotnet build) reruns the step. Switching back reruns it again.

Exporting Development data

The generated data records the environment in [assembly: BevelDataRegistration(..., Environment = "...")]. If you export data built for Development, Bevel logs a warning, because things meant only for Development (such as drafts) may be in it. Build with -c Release or set ASPNETCORE_ENVIRONMENT=Production to export production data.

In configuration

Configuration follows WebApplication.CreateBuilder: appsettings.json, appsettings.{Environment}.json, user secrets (Development only), then environment variables. The content root is the project directory.