【发布时间】:2011-11-07 17:46:28
【问题描述】:
我有一组模板文件,比如
<!-- @TEMPLATE@ -->
<!-- @DONOTEDIT@ -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>SuperDuper @VARIANT@</title>
</head>
<body>
...
@PRODUCTCODENAME@
...
</body>
我想使用NAnt 进行部署,以便实例化嵌入的关键字,如
<target name="deployTemplates">
<property name="_buildstamp" value="${DestDir}/templates_buildstamp"/>
<uptodate property="_uptodate" verbose="${Verbose}">
<sourcefiles basedir="${TemplateDir}">
<include name="**"/>
</sourcefiles>
<targetfiles>
<include name="${_buildstamp}"/>
</targetfiles>
</uptodate>
<if test="${not _uptodate}">
<copy todir="${CourseDestDir}" verbose="${Verbose}" overwrite="True">
<!-- Have to specify the fileset again to maintain directory structure. -->
<fileset basedir="${TemplateDir}">
<include name="**"/>
</fileset>
<filterchain>
<replacetokens>
<token key="DONOTEDIT" value="Do not edit, will be overwritten."/>
<token key="PRODUCTCODENAME" value="${Product}"/>
<token key="VARIANT" value="${Variant}"/>
</replacetokens>
</filterchain>
</copy>
<touch file="${_buildstamp}"/>
</if>
</target>
但是如何将各个模板文件的名称嵌入到每个部署的文件中,也就是说,将@TEMPLATE@ 替换为模板文件的位置,以便其他人知道在哪里进行永久更改?
【问题讨论】:
标签: nant