Build your webparts with NAnt
Well, first post for a long time now …
Following this post of my co-officer Renaud (himself following this one from Mads Nissen), I looked for a better way to build the CAB file, because I'm not an addict of his javascript hack. I thought it was possible, and I did.
The main problem when building the CAB file is how to generate the DDF file. How to get the content files of the project ? Of course by reading the CSPROJ file (nothing else than an XML file).
But the task can only get a single value, not a list of values. And more than one project have more than one content file. So, before coding a new task (not a bad thing to learn by the way), I googled a little bit of my time and found this post on the Serge's blog, inspired of this Richard Case post.
That's the solution : use task to get all file refs from CSPROJ file and write the ddf file accordingly. So :
- Create a temp directory
- Generate the DDF header lines in a file that you store in the temp dir with task <echo>, using attribute file. To change destination directory for the CAB file, change the .Set DiskDirectory1 parameter. Example : .Set DiskDirectory1=${project::get-base-directory()}/${build.dir}
- Get the compiled assembly (using <xmlpeek> task to get name and build location for the assembly from the CSPROJ ? Why not …), copy them into the temp directory and add the file name in the DDF file (use append attribute for task <echo> to avoid overwrite in the file).
- Use <xmllist> with xpath="//VisualStudioProject/CSHARP/Files/Include/File[@BuildAction='Content']/@RelPath", iterate in the list with the task <foreach> (delim="," if you didn't specify anything in the task <xmllist>), copy the corresponding file in the temp directory and add it to the DDF file.
- Now execute the makecab.exe with the task <exec> (using workingdir attribute can help).
- Delete the temp dir
It does the job. NAnt and community power ! Enjoy !
Note : A little bit of light info about the DDF file here.
Updated : This example may help.

This entry was posted
on Wednesday, July 27th, 2005 at 10:13 pm and is filed under Uncategorized.
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.
Build your webparts with NAnt
Well, first post for a long time now …
Following this post of my co-officer Renaud (himself following this one from Mads Nissen), I looked for a better way to build the CAB file, because I'm not an addict of his javascript hack. I thought it was possible, and I did.
The main problem when building the CAB file is how to generate the DDF file. How to get the content files of the project ? Of course by reading the CSPROJ file (nothing else than an XML file).
But the task can only get a single value, not a list of values. And more than one project have more than one content file. So, before coding a new task (not a bad thing to learn by the way), I googled a little bit of my time and found this post on the Serge's blog, inspired of this Richard Case post.
That's the solution : use task to get all file refs from CSPROJ file and write the ddf file accordingly. So :
- Create a temp directory
- Generate the DDF header lines in a file that you store in the temp dir with task <echo>, using attribute file. To change destination directory for the CAB file, change the .Set DiskDirectory1 parameter. Example : .Set DiskDirectory1=${project::get-base-directory()}/${build.dir}
- Get the compiled assembly (using <xmlpeek> task to get name and build location for the assembly from the CSPROJ ? Why not …), copy them into the temp directory and add the file name in the DDF file (use append attribute for task <echo> to avoid overwrite in the file).
- Use <xmllist> with xpath="//VisualStudioProject/CSHARP/Files/Include/File[@BuildAction='Content']/@RelPath", iterate in the list with the task <foreach> (delim="," if you didn't specify anything in the task <xmllist>), copy the corresponding file in the temp directory and add it to the DDF file.
- Now execute the makecab.exe with the task <exec> (using workingdir attribute can help).
- Delete the temp dir
It does the job. NAnt and community power ! Enjoy !
Note : A little bit of light info about the DDF file here.
Updated : This example may help.

This entry was posted
on Wednesday, July 27th, 2005 at 10:13 pm and is filed under Uncategorized.
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.