Example from Pierre Jacomet¶
These 2 examples (simplified and full blown) give a good example of how parameters can be used.
Especially the simplified one will be a good one for most people.
Simplified example¶
1<project name="Test Dynamic values">
2 <tasks>
3 <exec>
4 <!--# Note: do not use {} for executing powershell blocks because they conflict
5 with the normal .NET format marker. If you still want to use them,
6 then escape them, i.e.:
7 -->
8 <description>Test dynamic values with exec Powershell</description>
9 <executable>powershell</executable>
10 <buildArgs>-Command "$[CommandToRun]"</buildArgs>
11 </exec>
12
13 <exec>
14 <description>Test dynamic values with exec cmd</description>
15 <executable>cmd.exe</executable>
16 <buildArgs>/c "$[CommandToRun]"</buildArgs>
17 </exec>
18 </tasks>
19
20 <parameters>
21 <textParameter>
22 <name>CommandToRun</name>
23 <display>Which command you want to run</display>
24 <required>true</required>
25 </textParameter>
26 </parameters>
27
28 </project>
29
Full blown example¶
1<project name="Test Dynamic values">
2 <tasks>
3
4 <exec>
5 <!--# Note: do not use {} for executing powershell blocks because they conflict
6 with the normal .NET format marker. If you still want to use them,
7 then escape them, i.e.:
8
9 -->
10 <description>Test dynamic values with exec Powershell</description>
11 <executable>powershell</executable>
12 <dynamicValues>
13 <replacementValue property="buildArgs">
14 <format>-Command "{0}"</format>
15 <parameters>
16 <namedValue name="CommandToRun" value="Help" />
17 </parameters>
18 </replacementValue>
19 </dynamicValues>
20 </exec>
21
22 <exec>
23 <description>Test dynamic values with exec cmd</description>
24 <executable>cmd.exe</executable>
25 <dynamicValues>
26 <replacementValue property="buildArgs">
27 <format>/c "{0}"</format>
28 <parameters>
29 <namedValue name="CommandToRun" value="Help" />
30 </parameters>
31 </replacementValue>
32 </dynamicValues>
33 </exec>
34
35 </tasks>
36 <parameters>
37 <textParameter>
38 <name>CommandToRun</name>
39 <display>Which command you want to run</display>
40 <required>true</required>
41 </textParameter>
42 </parameters>
43
44 </project>
45