1. 程式人生 > >DOS工具: 自動從VSS獲取並編譯,複製,上傳,打包的工具

DOS工具: 自動從VSS獲取並編譯,複製,上傳,打包的工具

@echo off
rem -- =============================================
rem -- DESCRIPTION: <自動_VSS管理バッチ>
rem -- AUTHOR:  <>
rem -- CREATE DATE: <2010/12/27>
rem -- =============================================

rem ----------------------------
rem         Local Folder Name
rem ----------------------------
@set local_filename=vss_project
rem ----------------------------
rem         Vss_username
rem ----------------------------
@set vss_username=fanh

rem ----------------------------
rem         Vss_password
rem ----------------------------
@set vss_password=fanh

rem ----------------------------
rem         Local Folder path
rem ----------------------------
@set local_filepath=D:/

rem ----------------------------
rem          Application Name
rem ----------------------------
@set local_app_name=project.sln

rem ----------------------------
rem         Vss_project_path
rem ----------------------------
@set vss_project_path=$/code/project

rem ----------------------------
rem         Vss_dir
rem ----------------------------
@set vss_dir=//192.168.0.218/vss

rem ----------------------------
rem         Vss_install_path
rem ----------------------------
@set vss_install_path=C:/Program Files/Microsoft Visual SourceSafe

rem ----------------------------
rem         .net_install_path
rem ----------------------------
@set net_install_path=C:/Program Files/Microsoft Visual Studio 9.0/Common7/IDE

rem ----------------------------
rem         .rar_install_path
rem ----------------------------
@set rar_install_path=C:/Program Files/WinRAR

rem ----------------------------
rem         Local log Name
rem ----------------------------
@set local_logfile_name=build.log

rem ----------------pa----------------------------------------------
rem         コピー元範囲及びファイルタイプ_(default: txt)
rem --------------------------------------------------------------
@set file_type1=/project.App/bin
@set file_type2=/project.App/obj
@set file_type3=/*.scc
@set file_type4=/*.vssscc
@set file_type5=/*.vspscc
@set file_type6=/project.Common/bin
@set file_type7=/project.Common/obj
rem ----------------------------
rem         vss_flag(1:on, 0:off)
rem ----------------------------
@set vss_flag=1

rem ----------------------------
rem         build_flag(1:on, 0:off)
rem ----------------------------
@set build_flag=0

rem ----------------------------
rem         納品_flag(1:on, 0:off)
rem 不要なファイルを除くことができる
rem ----------------------------
@set order_flag=1

rem ----------------------------
rem         納品__Local Folder Name
rem ----------------------------
@set local_filename_order=vss_project1

rem ----------------------------
rem         RAR_flag(1:on, 0:off)
rem rarタイプで梱包することができる
rem ----------------------------
@set rar_flag=1

rem ----------------------------
rem         同元コピー_flag(1:on, 0:off)
rem 両方フォルダに同じファイルを同歩に更新することができる
rem ----------------------------
@set sameCopy_flag=0

rem ----------------------------
rem         同元コピー削除_flag(1:on, 0:off)
rem 両方フォルダに同じファイルを削除することができる
rem ----------------------------
@set sameCopy_flag_del=0

rem ----------------------------
rem         同元コピー_Local Folder Name
rem ----------------------------
@set local_filename_sameCopy=vss_aaa1

rem ----------------------------
rem         同元コピーVss_project_path
rem ----------------------------
@set vss_project_path_sameCopy=$/vss_aaa1

@set path=%path%;%vss_install_path%
@set ssdir=%vss_dir%
@set ssuser=%Vss_username%
@set sspwd=%Vss_password%

@if %vss_flag% EQU 1 goto do_vss
@if %build_flag% EQU 1 goto do_build
@goto sameCopy

@:do_vss
rem ----------------------------
rem         do vss
rem ----------------------------

@if not exist %local_filename% (md %local_filepath%%local_filename%)

echo /////////////////////////////////////////////////
echo get files from vss
echo /////////////////////////////////////////////////
@ss workfold %vss_project_path% %local_filepath%%local_filename%
@ss get -GL%local_filepath%%local_filename% %vss_project_path% -R -W -I-

@if %build_flag% EQU 1 goto do_build
@goto sameCopy
 
@:do_build
rem ----------------------------
rem         do build
rem ----------------------------
echo -- ===========================================================
echo build starting
echo -- ===========================================================
@set path=%path%;%net_install_path%
@if exist %local_filepath%%local_logfile_name% (del %local_filepath%%local_logfile_name%)
@devenv /build release %local_filepath%%local_filename%/%local_app_name% >>%local_filepath%%local_logfile_name%
@if errorlevel 1 goto error
@goto success
@:error
echo;
echo -- ===========================================================
echo build failure
echo -- ===========================================================
@goto end
@:success

echo;
echo -- ===========================================================
echo build success
echo -- ===========================================================
@goto sameCopy

@:sameCopy
@if %sameCopy_flag% NEQ 1 goto sameDelete
rem ----------------------------
rem         同元コピー
rem ----------------------------

@if not exist %local_filename% (md %local_filepath%%local_filename_sameCopy% && xcopy %local_filepath%%local_filename% %local_filepath%%local_filename_sameCopy% /S /Y && DEL %local_filepath%%local_filename_sameCopy%%file_type3% /S/Q && DEL %local_filepath%%local_filename_sameCopy%%file_type4% /S/Q && ss create /%local_filename_sameCopy% -Y%Vss_username%,%Vss_password% -I-Y -C && ss cp /%local_filename_sameCopy% -Y%Vss_username%,%Vss_password% -I-Y && ss add %local_filepath%%local_filename_sameCopy% -R -Y%Vss_username%,%Vss_password% -I-Y -C -W && @goto end)
@ss cp %vss_project_path_sameCopy% -Y%Vss_username%,%Vss_password% -I-Y && @ss workfold %vss_project_path_sameCopy%/%local_filename_sameCopy% %local_filepath%%local_filename_sameCopy% -Y%Vss_username%,%Vss_password% -I-Y && D: && CD %local_filepath%%local_filename_sameCopy% && @del *.* /s/q/f && @ss checkout %vss_project_path_sameCopy%/%local_filename_sameCopy% -R -Y%Vss_username%,%Vss_password% -I-Y -C && @xcopy %local_filepath%%local_filename% %local_filepath%%local_filename_sameCopy% /S /Y /U /R && @ss checkin %vss_project_path_sameCopy%/%local_filename_sameCopy% -R -Y%Vss_username%,%Vss_password% -I-Y -C -W && CD / && goto end

@:sameDelete
@if %sameCopy_flag_del% NEQ 1 goto do_order
rem ----------------------------
rem         同元削除
rem ----------------------------
@ss destroy %vss_project_path_sameCopy% -Y%Vss_username%,%Vss_password% -I-Y && @ss cp $ -Y%Vss_username%,%Vss_password% -I-Y
goto do_order

@:do_order
@if %order_flag% NEQ 1 goto do_order
rem ----------------------------
rem         do order
rem ----------------------------
@IF EXIST %local_filepath%%local_filename_order% (DEL %local_filepath%%local_filename_order%%file_type1% /S/Q/F & DEL %local_filepath%%local_filename_order%%file_type2% /S/Q/F & DEL %local_filepath%%local_filename_order%%file_type6% /S/Q/F & DEL %local_filepath%%local_filename_order%%file_type7% /S/Q/F && DEL %local_filepath%%local_filename_order%%file_type3% /S/Q/F && DEL %local_filepath%%local_filename_order%%file_type3% /S/Q/F/A:H && DEL %local_filepath%%local_filename_order%%file_type4% /S/Q/F && DEL %local_filepath%%local_filename_order%%file_type5% /S/Q/F && goto do_rar)

@:do_rar
@if %rar_flag% NEQ 1 goto end
rem ----------------------------
rem         do rar
rem ----------------------------
@set path=%path%;%rar_install_path%
@IF EXIST %local_filepath%%local_filename_order% (D: && CD %local_filepath%%local_filename_order% && rar a %local_filepath%%local_filename_order% -r && cd /)
echo;
echo -- ===========================================================
echo rar success
echo -- ===========================================================

@:end
pause