Configure your environment
You can create an environment configuration file that allows you to define and control environment settings for all your environments (for example, development and production) in one place. You do this by creating a new application setting that's specific to the current environment, and overrides other environment configurations.
To create an environment-specific configuration:
-
Create a
web.config.xdttransformation file that includes a new app setting, for example, setting the environment name toDEV:RequestResponse<?xml version="1.0" encoding="utf-8"?> <configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"> <appSettings> <add xdt:Transform="InsertIfMissing" xdt:Locator="Match(key)" key="customenvironment:define" value="DEV" /> </appSettings> </configuration> -
Include the web config file in the Platform project:
RequestResponse<ItemGroup> <Content Include="xdts\Web.config.xdt"> <CopyToOutputDirectory>Always</CopyToOutputDirectory> </Content> </ItemGroup> -
In the build configuration file
(xmcloud.build.json), create a mapping for thexdtfile:RequestResponse"transforms": [ { "xdtPath": "/xdts/web.config.xdt", "targetPath": "/web.config" } ]XM Cloud is now SitecoreAISome code examples, images, and UI labels may still use XM Cloud while engineering assets are being updated.
-
Create an environment variable named
SITECORE_APPSETTINGS_customenvironment__define. This overrides thecustomenvironmentapp setting. Enter a meaningful value for the variable: in this example, in step 1, the default name is set to DEV, and you can use this variable to change it to PROD. -
Create an environment-specific configuration in the
settingsattribute and include it in the project. This example shows how you use the new app setting to drive other configurations:RequestResponse<?xml version="1.0" encoding="utf-8" ?> <configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:customenvironment="http://www.sitecore.net/xmlconfig/pskenvironment/"> <sitecore> <settings> <setting name="Xdt.Test" value="None"> <patch:attribute name="value" value="DEV" customenvironment:require="DEV" /> <patch:attribute name="value" value="QA" customenvironment:require="QA" /> </setting> </settings> </sitecore> </configuration> -
Create a build and deploy it. This is required for the changes to take effect.