티스토리 뷰

필요 조건 목록
  1. subversion 서버의 최신 데이터 받는다.
  2. 빌드 버전을 빌드한 날짜와 빌드 넘버를 표시한다.
  3. 하위 경로에 있는 sln파일을 찾아서 빌드 한다.
원래는 batch 파일로 제작을 하다가, 빌드 버전과 날짜를 표시 할려고 했더니... batch파일로는 복잡해 져서 포기하고 Nant를 사용해서 새로 스크립트를 작성 했습니다.
Nant를 공부하면서 제작한거라, 부족한 점이 많지만, 혹시 저 처럼 고생하시는 분에게 도움이 될까 해서 공개합니다.
조언이나 잘 못 된 점이 있으면 적어 주세요.


<?xml version="1.0"?>
<project name="TaklPlay" default="build">
    <property name="configuration" value="release"/>
	<property name="date.now" value="${ datetime::now() }"/>
	<property name="month.now" value="${ datetime::get-month( date.now )}"/>
	<property name="month.now" value="0${ month.now }" if="${ int::parse( month.now ) < 10 }"/>
	<property name="day.now" value="${ datetime::get-day( date.now )}"/>
	<property name="day.now" value="0${ day.now }" if="${ int::parse( day.now ) < 10 }"/>
	<property name="timestamp" value="${month.now}${day.now}"/>

	<!--clean -->
    <target name="clean" description="remove all generated files">
		<delete verbose="true">
			<fileset>
				<include name="**/bin/**" />
				<include name="**/Release/**" />
                <include name="**/*.suo" />
                <include name="**/*.user" />
			</fileset>
		</delete>
    </target>

	<!-- 버전 정보 만들기 -->
	<target name="replaceVersion" description="replce file version">
		<foreach item="File" property="filename">
			<in>
				<items >
					<include name="**/*.rc" />
				</items>
			</in>
			<do>
				<echo message="resource : ${filename}" />
				<loadfile file="${filename}" property="fileContent" verbose="false" />
				<regex pattern="(?'major'\d+)*,(?'minor'\d+)*,(?'buildDate'\d+)*,(?'buildNumber'\d+)" input="${fileContent}" />
				<property name="newBuildNumber" value="${int::parse(buildNumber)+1}" />
				<echo message="old version : ${major},${minor},${buildDate},${buildNumber}"/>
				<echo message="build version : ${major},${minor},${timestamp},${newBuildNumber}"/>
				<copy file="${filename}" tofile="${filename}.tmp" verbose="true"
					overwrite="true">
					<filterchain>
						<replacestring from="${major},${minor},${buildDate},${buildNumber}"
							to="${major},${minor},${timestamp},${newBuildNumber}" ignorecase="true" />
						<replacestring from="${major}, ${minor}, ${buildDate}, ${buildNumber}"
							to="${major}, ${minor}, ${timestamp}, ${newBuildNumber}" ignorecase="true" />
					</filterchain>
				</copy> 
				<delete file="${filename}" />
				<move file="${filename}.tmp" tofile="${filename}" />
			</do>
		</foreach>
	</target>

	<!-- build -->
    <target name="build" description="compiles the source code">
		<exec program="svn.exe" commandline="up">
		</exec>
		
		<foreach item="File" property="filename">
			<in>
				<items >
					<include name="**/*.sln" />
				</items>
			</in>
			<do>
				<exec program="C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\devenv.com" commandline="/rebuild ${configuration} ${filename}"> 
			</exec>
			</do>
		</foreach>
    </target>

	<!-- rebuild -->
	<target name="rebuild" depends="clean, build" />

	<!-- all 전체 작업. -->
	<target name="all" depends="clean, replaceVersion, build">
		<!-- rc파일을 commit해 준다. -->
		<foreach item="File" property="filename">
			<in>
				<items >
					<include name="**/*.rc" />
				</items>
			</in>
			<do>
				<exec program="svn.exe" commandline="commit ${filename} -m Project_Auto_Build." />
			</do>
		</foreach>
    </target>
</project>
댓글
댓글쓰기 폼
공지사항
Total
1,667,612
Today
0
Yesterday
137
«   2019/12   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        
글 보관함