-
Notifications
You must be signed in to change notification settings - Fork 5
Syntax
The template engine works with simple templates files with placeholders which will be resolved to a string.
In order to create a template file for your config file xxxxx.yyy
, just create a file named xxxxx.template.yyy
.
Example:
-
App.template.config
-->App.config
-
Web.template.config
-->Web.config
Inside the template file you can use ${variable}
as placeholders. Example:
<?xml version="1.0" encoding =" utf-8" ?>
<configuration>
<appSettings>
<add key="firstname" value= "${firstname}" />
<add key="lastname" value= "${lastname}" />
</appSettings>
</configuration>
For each environment create a xml file named to the environment.
local.xml
<?xml version="1.0"?>
<environment description="local environment">
<variable name="Firstname" value="Jack " />
<variable name="Lastname" value="Bauer " />
</environment>
Note: you can use ${env}
which contains the name of the environment.
dev.xml
<? xml version=" 1.0" ?>
<environment description="dev system for developers" >
<variable name="Firstname" value="Tobias" />
<variable name="Lastname" value="Zuercher " />
</environment>
The environment files must be stored in a folder called .powerdeploy
. During transformation, the engine will look for the .powerdeploy
folder in all parent paths starting with the targeting path.
Install-Package PowerDeploy.PackageManagerExtension
TODO
Syntax | Description |
---|---|
${variable} | variable with the name "variable". if this variable is not defined, a warning message will apear. |
${host=localhost} | variiable with the name host. if the variable is not specified, localhost is used. |
${env} | is an automatic generated variable which contains the name of the environment. |
Sometimes you want to have a bigger block in the config if a condition is true (for example turn on WCF Tracing). For this, there is a simple if construct:
<!-- [if ${backend.tracing.enabled}] -->
<system.diagnostics>
<sources>
<!-- WCF Message Tracing -->
<source name="System.ServiceModel.MessageLogging">
<listeners>
<add name="messages" type="System.Diagnostics.XmlWriterTraceListener" initializeData="${log.path}WCF_MessageLogging.svclog"/>
</listeners>
</source>
</sources>
</system.diagnostics>
<!-- [endif] -->
What happens here:
First the variable ${backend.tracing.enabled}
gets resolved to a value. if this value is "true"
, "on"
, "enabled"
or "1"
then everything which is betweend the <!-- [if ....]-->
and <!-- [endif] -->
will be in the transform output, otherwise the whole block is skipped.
Note: There is no else or any operator for the if statement like equals.
Basic structure:
<?xml version="1.0">
<environment description="some description about the environment" include="common.xml">
<variable name="variable1" value="value1" />
<variable name="variable" value="value2" />
<variable name="combined" value="Variable1: ${variable1}; Variable2: ${variable2}" />
</environment>
The include
attribute lets you include the variables from another file. Use comma to separate different files. This is useful for variables which have the same value in multiple environments, so you don't have to copy and paste those variables. It's important that the included variables won't overwrite any existing variable! See the Best Practices Chapter for more detaiils how to use this feature properly.
ideas: Tool/Integration/Plugin should support your work and not hide the complexity!