Source code for contributions to the Octopus Deploy Library
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Build status


Source code for contributions to the Octopus Deploy Library.


A PowerShell script to set an ASP.NET Core runtime environment variable in a web.config file.

The most likely use for this is to take advantage of the MVC Environment tag helpers now available in ASP.NET Core.

The benefit of setting an environment variable in web.config is that not only will the scope be restricted to the runtime of the app, but it will also take precedence over corresponding ones found in IIS, user environment variables or system environment variables. This means it is easier to independently configure apps deployed on the same machine.

In addition, web.config transforms are no longer an option in ASP.NET Core. If you use a token substitution method to manage environment variables in web.config, it will likely break your local configuration.


  • anc_WebConfigPath: The path to the web.config file, typically derived from an output variable in a previous step
  • anc_EnvironmentVariableName: Name of environment variable to set
  • anc_EnvironmentVariableValue: Value of environment variable to set