CLI and environment

The --bevel-build flag, environment variables, build environment and exit codes that control exports and the data step.

On this page
bash
dotnet run -c Release -- --bevel-build            # export to the default folder
dotnet run -c Release -- --bevel-build dist       # export to ./dist
BEVEL_BUILD=true dotnet run -c Release            # same, from the environment

You export a Bevel site by running your own app in export mode. Bevel renders every static route, writes the files, then stops. It binds no ports.

Command-line flags

Flag Meaning
--bevel-build Turn on export mode.
--bevel-build <dir> or --bevel-build=<dir> Export mode, writing to <dir>.
--bevel-out <dir> or --bevel-out=<dir> Set the output folder. Does not turn on export mode by itself.

Flags are case-insensitive. A relative <dir> resolves against the content root.

Environment variables

Variable Meaning
BEVEL_BUILD true or 1 turns on export mode when no flag is given.
BEVEL_OUT Output folder for BEVEL_BUILD.
ASPNETCORE_ENVIRONMENT, DOTNET_ENVIRONMENT Build environment for the data step, ahead of BevelEnvironment. Also decides live or exported serving at run time.
DOTNET_gcServer Set to 0 to cut peak memory during an export.
DOTNET_GCHeapHardLimit Cap the heap, such as 0x40000000 for 1 GB.

Configuration key Bevel:RepoRoot overrides how Bevel finds the repo root for @/ paths in processors.

Which output folder wins

Bevel picks the first of these that is set:

  1. BevelOptions.ExportOutputPath
  2. The folder from --bevel-build <dir>, --bevel-out or BEVEL_OUT
  3. BevelOptions.OutputPath
  4. wwwroot

BevelOptions.ExportOnStart forces export mode on or off, whatever the flags say.

Bevel refuses unsafe folders: a filesystem root, your home directory, the content root or its ancestors, a symbolic link, or any folder holding a .csproj, .sln, .slnx or .git entry. --bevel-build . fails without touching anything.

Build environment

The data step runs as Development in a Debug build and Production in a Release build. Bevel resolves it from, in order, ASPNETCORE_ENVIRONMENT, DOTNET_ENVIRONMENT, then MSBuild.BevelEnvironment. Changing it reruns the data step.

Publish export

Set MSBuild.BevelExportOnPublish and dotnet publish runs the export for you. Bevel starts the export child process with DOTNET_gcServer=0 unless you already set it. It writes to MSBuild.BevelOutputPath, which defaults to $(PublishDir)wwwroot.

Exit codes

Code When
0 The export finished, including every AfterExport step.
1 A page failed, an output path was refused, or an export step threw.

The files are already written when an export step fails. Cancellation of an export step passes through as it is.