Ad

How Do I Automate Repetitive Tasks Post-build?

I run an ASP.NET website solution with a few other projects in it. I've known that MSBuild projects are capable of this, but is it the best way? Are they easy to create? Is nAnt, CruiseControl.NET or any other solution better?

When I build the site (using Web Deployment Projects), can I automate part of the build so that it does not copy certain folders from the project into the Release folder? For instance, I have folders with local search indexes, images and other content part of the folder, but I never need or upload those when deploying the project.

I'm also looking toward this type of solution to automatically increment build and version numbers.

Ad

Answer

Here's an example of a Web Deployment Project scripting this sort of task in the .wdproj file:

  <Target Name="AfterBuild">
    <!-- ============================ Script Compression============================ -->
    <MakeDir Directories="$(OutputPath)\compressed" />
    <Exec Command="java -jar c:\yuicompressor-2.2.5\build\yuicompressor-2.2.5.jar --charset UTF-8 styles.css -o compressed/styles.css" WorkingDirectory="$(OutputPath)" />
    <Exec Command="move /Y .\compressed\* .\" WorkingDirectory="$(OutputPath)" />
    <RemoveDir Directories="$(OutputPath)\sql" />
    <Exec Command="c:\7zip-4.4.2\7za.exe a $(ZipName).zip $(OutputPath)\*" />
  </Target>

This would allow you to delete a folder.

(I suspect that if you wanted to not have the folder copy over at all, the solution file would be the place to specify that, though I haven't had to use that.)

Ad
source: stackoverflow.com
Ad