Simple Nant Build file - revert switch update

Nant you might all know is a powerful tool when creting builds.It offers lot of flexibility when it come to building projects.Nant along with subversion and wix can make your life easier to build your app.Here is a simple post that shows you how to use nant and get files.

Following script does
1.Clenup
2.Switch
3.remove unversioned files and directories
 4.revert
5.update

<?xml version="1.0" encoding="utf-8"?>
<project name="testscriptfile" default="build" basedir=".">

<property name="subversion.username" value="YourUserName" />
<property name="subversion.password" value="YourPassWord" />

<property name="subversion.projectpath" value="YoutPath" />
<property name="dir.project" value="yourPhysicalFilesPath" />

<property name="subversion.revision" value="-1" />
<property name="subversion.projectpathwithrevision" value="" />

<target name="setdependencyproperties">
<property name="subversion.projectpathwithrevision" value="${subversion.projectpath}" />
<if test ="${subversion.revision > '-1'}">
<property name="subversion.projectpathwithrevision" value="${subversion.projectpath} -r ${subversion.revision}" />
</if>
</target>


<target name="build" description="gets the latest files from subversion" depends ="setdependencyproperties">

<echo message="#######################################" />
<echo message="CLEANING : ${dir.project}" />
<echo message="#######################################" />
<exec program="svn" commandline="cleanup ${dir.project}" />
<echo message=" " />


<echo message="#######################################" />
<echo message="REVERTING : ${dir.project}" />
<echo message="#######################################" />
<exec program="svn" commandline="revert --recursive ${dir.project}" />
<echo message=" " />

<echo message="#######################################" />
<echo message="REMOVING UNVERSIONED FILES/DIRS FROM : ${dir.project}" />
<echo message="#######################################" />

<exec program="cmd">
<arg value="/k"/>
<arg value="for /f &quot;tokens=1*&quot; %i in ('svn status ${dir.project} ^| find &quot;?&quot;') do del /q &quot;%j&quot;"/>
</exec>

<exec program="cmd">
<arg value="/k"/>
<arg value="for /f &quot;tokens=1*&quot; %i in ('svn status ${dir.project} ^| find &quot;?&quot;') do rd /s /q &quot;%j&quot;"/>
</exec>

<echo message=" " />

<echo message="#######################################" />
<echo message="SWITCHING : ${subversion.projectpathwithrevision}" />
<echo message="#######################################" />
<exec program="svn" commandline="switch ${subversion.projectpathwithrevision} ${dir.project} " />
<echo message=" " />

<echo message="#######################################" />
<echo message="GETTING FILES FROM : ${subversion.projectpathwithrevision} TO ${dir.project}" />
<echo message="#######################################" />
<exec program="svn" commandline="update --username ${subversion.username} --password ${subversion.password} ${subversion.projectpathwithrevision} ${dir.project}" />

</target>
</project>

Comments

Popular posts from this blog

Duplicate Folders Freeware - Not Duplicate Files

SSRS Compile Errors

Free SQL Server Management Studio Addin/Plugin/External Tool to get object information quickly