今天分享个版本生成的批处理文件^ ^,拿来改改就可以用了。
REM 删除日志文件
del C:\Releaselog.txt
REM 创建目录
RD e:\ProjectBuild /s/q >>C:\Releaselog.txt
MD e:\ProjectBuild >>C:\Releaselog.txt
REM 签出代码
svn.exe checkout http://xxx.xx.xxx.xxx:xxxx/svn/Demo/trunk e:/ProjectBuild >>C:\Releaselog.txt
REM 把当前路径改到代码路径
e: >>C:\Releaselog.txt
REM 脚本放在了项目路径的Script的make文件夹下了。
cd e:\ProjectBuild\Script\make >>C:\Releaselog.txt
::获得当前时间,作为生成版本的目录名
for /F "tokens=1-4 delims=- " %%i in ('date /t') do (
set Year=%%i
set Month=%%j
set Day=%%k
)
for /F "tokens=1-2 delims=: " %%i in ('time /t') do (
set Hour=%%i
set Minute=%%j
)
REM 版本定义
set Version=1
REM 变量定义
REM 日期时间
set DateTime=%Year%-%Month%-%Day%-%Hour%-%Minute%
REM 解决方案路径、文件名
set SolutionName=..\..\solutionwin\Demo.sln
REM winrar 软件路径
set RAR_ROOT=C:\Program Files\WinRAR
REM 版本、备份代码存放路径。暂为本脚本所在路径
set VersionDirectory=版本生成\%DateTime%
REM 日志文件名
set LogFile=%VersionDirectory%\Demo%DateTime%.log
REM 标签名称
set LabelName=Demo_Win32_%DateTime%
::创建目录
mkdir %VersionDirectory%
@echo ----------------------正在打标签-------------------------------->> %LogFile%
svn.exe copy http://xxx.xx.xxx.xxx:xxxx/svn/Demo/trunk http://xxx.xx.xxx.xxx:xxxx/svn/Demo/tags/%LabelName% -m "%LabelName"
@echo ----------------------正在编译解决方案-------------------------------->> %LogFile%
"%vs71comntools%..\ide\devenv" /build "Debug" "%SolutionName%" /out "%LogFile%"
"%vs71comntools%..\ide\devenv" /build "Release" "%SolutionName%" /out "%LogFile%"
REM 复制发布版本中的需要的文件
:: C/CPP Head Files
xcopy /y /i /k /r /s "..\..\include\*.h" "temp\include\" >> %LogFile%
REM ------------------------------------需要打包的文件----------------------------------------------------------------------------
xcopy /y /i /k /r "..\..\bin\win32dbg\xxxxxxxx_d.dll" "temp\Bin\Debug\" >> %LogFile%
xcopy /y /i /k /r "..\..\bin\win32rel\xxxxxxxx.dll" "temp\Bin\Release\" >> %LogFile%
@echo ---------------------正在拷贝编译生成的文件----------------------------- >> %LogFile%
cd temp
del /F /Q ..\%VersionDirectory%\demo.rar
"%RAR_ROOT%\RAR.exe" -esh a -r -o+ ..\%VersionDirectory%\demo.rar "*.*"
@echo ----------------------正在删除临时文件---------------------------------->> %LogFile%
cd..
rd /Q /S temp
REM 移动到历史目录
MD d:\Demo\HistoryVer\%LabelName%
xcopy /y /i /k /r /s 版本生成\%DateTime%\*.* D:\Demo\HistoryVer\%LabelName% >> %LogFile%
copy C:\Releaselog.txt d:\Demo\HistoryVer\%LabelName%
REM 删除路径以保证每个版本Dll上的时间戳都是正确的
cd \
explorer D:\Demo\HistoryVer\%LabelName%
REM 退出
exit /B 0