0
votes

Hi I new to nant and am looking to make some kind of function/task that groups a bunch of regular nant tasks.

Basically I have 3 websites with web.config files that I need to write the connectionstring and imageDir values 2, only the file path changes

Currently I am looping through the a csv of file paths to accomplish this but would like to be able to pull the code out of the loop and make it a task/function/target or something. What is the best approach.

        <foreach item="String" in="${webConfig.includedFilePaths}" delim="," property="File.Path">
            <do>
                <xmlpoke
                    file="${File.Path}"
                    xpath="${connectionString.XPath}"
                    value="${connectionString.Value}" />
                <xmlpoke
                    file="${File.Path}"
                    xpath="${imageDir.XPath}"
                    value="${imageDir.Value}" />
            </do>
        </foreach>

I am hoping for something like:

<writeWebConfig file=${file.Path}"
1

1 Answers

0
votes

You can create a custom nant task with a property like:

  <target name="UpdateConfig">
    <property name="config.filepath" value="" />
    <!-- Rest of the task code here -->
  </target>

And then you can call this task as many times as you want with the custom value of the property config.filepath. You can override the property value from command line using -D like:

-D:config.filepath=D:\TestWeb\web.config