1. 程式人生 > >vs2013 批處理程式自動編譯例項

vs2013 批處理程式自動編譯例項

1、編譯release例項指令碼如下:

@echo off
set debugOrRelease=Release
set baseOutPath=%debugOrRelease%


rem 當前指令碼所在路徑
set build_root = %~dp0
 
rem vcvarsall.bat所在的路徑:
set vcvars="%VS120COMNTOOLS%../../VC/vcvarsall.bat"
set devenv="%VS120COMNTOOLS%../IDE/devenv.exe"


rem 設定解決方案的路徑
set thesln=./test.sln


echo 開始編譯 
echo on 


echo 正在編譯,請稍後...
@%devenv% %thesln% /rebuild %baseOutPath% /out build.log
@endlocal
@notepad build.log


@PAUSE

注意:bat檔案與.sln檔案在同一資料夾下;若需要編譯其他的debug,則只需要修改set debugOrRelease=Release即可。

2、以上指令碼參考如下:

@echo off
set debugOrRelease=debug
set baseOutPath=..\09.臨時版本\Circus\%debugOrRelease%
set driverOutPath=%baseOutPath%\Config
set catPath=%driverOutPath%\Cat
set dogPath=%driverOutPath%\Dog


set CircusInPath=Circus\bin\%debugOrRelease%
set catInPath=Cat\bin\%debugOrRelease%
set dogInPath=Dog\bin\%debugOrRelease%


echo 輸出路徑
echo.%driverOutPath%
echo.%catPath%
echo.%dogPath%


@PAUSE 
echo 開始編譯 
%windir%\microsoft.net\framework\v4.0.30319\msbuild  Circus.sln /p:Configuration=%debugOrRelease% /t:Rebuild


@PAUSE
echo 開始複製
if not exist %catPath% md  %catPath%
if not exist %dogPath% md  %catPath%


echo  複製Circus
xcopy %CircusInPath% %baseOutPath%  /S /Y


echo  複製Cat
copy  %catInPath%\Cat.dll %catPath%   /Y


echo 複製Dog
xcopy %dogInPath% %dogPath%  /S /Y


echo 複製完畢
@PAUSE