NAnt: concatenate filenames
I'm currently constructing some NAnt build scripts for our continuous integration build environment for SharePoint development. One thing I want to do is that on the development server is that I want to install compiled web part assemblies and their references assemblies using the InstallAssemblies tool. This tool has in the command line version the option to install a set of assemblies using the "assembly:x,y,z" parameter. This parameter needs to have the assembly files separated by ','. I concatenate those filenames using the following code:
<project name="concat.test" default="concat.filenames" basedir=".">
<target name="concat.filenames" description="concatenate filenames">
<property name="concatenated.filenames" value=""/>
<foreach item="File" property="filename">
<in>
<items>
<include name="files\*.*" />
</items>
</in>
<do>
<property name="concatenated.filenames" value="${concatenated.filenames}${filename},"/>
</do>
<!-- now remove the trailing ',' -->
</foreach>
<property name="concatenated.filenames" value="${string::substring(concatenated.filenames, 0, string::get-length(concatenated.filenames) - 1)}"/>
<echo message="${concatenated.filenames}"/>
</target>
</project>
Result: [echo] C:\projects\NantTest\files\file1.txt,C:\projects\NantTest\files\file2.txt,C:\projects\NantTest\files\file3.txt