posted on Tuesday, August 30, 2005 3:03 PM
by
richardSlade
A custom Nant task for deployment
Finally.I got round to automatically deploying our web projects to our development server today in our build script. I thought that it was all going to be very easy. After all, Nant has lots of tasks, ready made to choose from.
When I came o have a look at it, I found that the standard copy task would probably not be suitable. After all, I don't want every file moving over to the dev server from the build server. So the next thing was to look into writing a custom Nant task.
Can I copy project?
First, I thought that I would try and use the EnvDte and VSLangProj references to build a programmatic CopyProject feature, like the one that is built into Visual Studio. This turned out to be pretty easy to code as I have done this before but the problem was that didn't have a version of VS.NET on the build server, just the SDK, and the CopyProject feature needs to create an instance of Visual Studio from its progId. Goodbye to that idea.
Bespoke Copy
In the end, I threw together a class, based on the Nant.Core tasks that would simply copy all files and folders recursively from the source to the target. I am also able to supply a list of files that I don't want to carry over. Something like this:
< copyproject source="C:\Inetpub\wwwroot\MyWebFolder" target="\\MyDevServer\share$\website\MyWebFolder" >
< excludefiles >
< fileextension name="VS Project Files" value=".csproj" />
< fileextension name="VSS Files" value=".vss" />
< excludefiles />
< copyproject />
This is great, but I'll be looking for a way to improve this. I had a bit of a look over the other Nant contrib tasks but couldn't immediately see anything that would be of use. Still, this only took a couple of hours to do and it all works pretty well. Build time is still small for a solution containing 22 projects with a complete deployment of 6 web projects to 2 web servers.
Cheers
R