要手工维护多个branch的代码有点麻烦,原先设想ftp的文件同步,后来觉得nant就够了,而且nant支持script后能做的事情更多了。
用nant原理很简单,daily build的机器从source control服务器获得最新的代码,编译、备份、压缩发布到http服务器。
然后每个branch的机器用nant备份旧代码,再用http服务器下载的新代码来替换掉旧代码。
最简单的例子。
<?xml version="1.0"?>
<project name="myproject" default="build" basedir=".">
<property name="myproject.codefilename" value="code.zip" readonly="true" />
<property name="myproject.codesourceurl" value="http://myserver/code/code.zip" readonly="true" />
<property name="myproject.zipfolder" value=".\temp" />
<property name="myproject.applicationdir" value="C:\tempfolder" />
<target name="clean">
<delete>
<fileset>
<include name="${myproject.codefilename}"/>
<include name="${myproject.zipfolder}/*.*"/>
<include name="${myproject.zipfolder}/**" />
</fileset>
</delete>
</target>
<target name="downloadcode" >
<get src="${myproject.codesourceurl}" dest="${myproject.codefilename}">
<credentials username="name" password="password" domain="domain" />
</get>
<unzip zipfile="${myproject.codefilename}" todir="${myproject.zipfolder}"/>
</target>
<target name="build" depends="downloadcode" >
<copy todir="${myproject.applicationdir}" flatten="false" overwrite="true">
<fileset basedir="${myproject.zipfolder}">
<include name="**" />
<exclude name="**/*.config" />
</fileset>
</copy>
<call target="clean" />
</target>
</project>
打印 | 张贴于 2005-04-06 23:10:00 | Tag:Dot Net

留言反馈
=================
你开始设想的FTP是什么思路的?
可是我想发布到远程的WEB服务器。可以采用FTP吗?试了一天,没有成功。象ftp这种有多步操作的,NANT要怎么实现呢?能实现吗?
编译好的copy到web虚拟目录下
非常高兴读到你的这篇文章。
有有一个疑问一直没有实现,就是发布到web服务器是如何实现的?可以指导一下吗?
<exec program = "../tools/bin/soscmd.exe" >
<arg value = "-soshome"/>
<arg value = "."/>
<arg value = "-command"/>
<arg value = "GetProject"/>
<arg value = "-server"/>
<arg value = "ip"/>
<arg value = "-name"/>
<arg value = "username"/>
<arg value = "-password"/>
<arg value = "userpass"/>
<arg value = "-alias"/>
<arg value = "anmp"/>
<arg value = "-project"/>
<arg value = "$/src"/>
<arg value = "-workdir"/>
<arg value = "src/ns"/>
<arg value = "-recursive"/>
<arg value = "-nocache" />
</exec>