首页 > 代码库 > 你还在手动发布代码吗?累不?

你还在手动发布代码吗?累不?

1、Auto_Build_EAS.bat

@echo off 

@echo -------------------------
@echo Only change variables below
set MSBuildDir=%WINDIR%\Microsoft.NET\Framework\v3.5
set BuildType=Release
set WorkingSpace=D:\workingspace\projects\shgt_erp\trunk
set SourceDir=%WorkingSpace%\02-Sources
set SolutionDir=%SourceDir%\N-EAS
set SolutionPath=%SolutionDir%\NI.EAS.All.sln
set BinOutput=BinOutput

rem cd to the folder of this command
pushd %~dp0

@echo -------------------------
@echo Start to get latest and build NI.EAS.All solution

@echo Remove old log files
del logs\ /Q /S /F

@echo -------------------------
@echo Get Lastest for %WorkingSpace%
svn update %WorkingSpace%
@echo Get Lastest Finished
@echo -------------------------

@echo Clear BinOutput
del %SolutionDir%\%BinOutput%\ /Q /S /F
@echo Clear Binoutput Finished
@echo -------------------------

@echo Building Start

call %MSBuildDir%\msbuild %SolutionPath% /t:Rebuild /p:Configuration=%BuildType% >> logs\NI.EAS.log

@echo Building Finsihed
@echo -------------------------

find "0 Error(s)" logs\NI.EAS.log && echo "no error" > logs\no_error.txt

if exist logs\no_error.txt (goto succeed) else (goto failed)

:succeed

call Deploy.bat %SolutionDir%

call Deploy_Jobs.bat %SourceDir% %BuildType%

echo deploy succeed

pause
exit

:failed
echo deploy failed

pause
exit

----------------------------------------------------------------------------
2、Deploy.bat

set SolutionDir=%1

set DestDir=D:\EAS

set ServiceDir=%SolutionDir%\Service
set ServiceDestDir=%DestDir%\Service

set PortalDir=%SolutionDir%\Portal\NI.EAS.Presentation.Web
set PortalDestDir=%DestDir%\NI.EAS.Presentation.Web

set APIDir=%SolutionDir%\Portal\NI.EAS.Presentation.API
set APIDestDir=%DestDir%\NI.EAS.Presentation.API


@echo Backup the latest version
del bak\ /Q /S /F
xcopy %DestDir%\*.* bak\ /S /Y /exclude:skipFiles.txt


@echo Copy to destination

net stop w3svc

xcopy %ServiceDir%\*.* %ServiceDestDir%\ /S /D /Y /exclude:skipFiles.txt
xcopy %PortalDir%\*.* %PortalDestDir%\ /S /D /Y /exclude:skipFiles.txt
xcopy %APIDir%\*.* %APIDestDir%\ /S /D /Y /exclude:skipFiles.txt

net start w3svc
iisreset /restart

----------------------------------------------------------------------------
3、Auto_Build_Jobs.bat
@echo off 

@echo -------------------------
@echo Only change variables below
set MSBuildDir=%WINDIR%\Microsoft.NET\Framework\v3.5
set BuildType=Release
set WorkingSpace=D:\workingspace\projects\shgt_erp\trunk
set SourceDir=%WorkingSpace%\02-Sources
set SolutionDir=%SourceDir%\N-EAS
set SolutionPath=%SolutionDir%\NI.EAS.All.sln
set BinOutput=BinOutput

rem cd to the folder of this command
pushd %~dp0

@echo -------------------------
@echo Start to get latest and build NI.EAS.All solution

@echo Remove old log files
del logs\ /Q /S /F

@echo -------------------------
@echo Get Lastest for %WorkingSpace%
svn update %WorkingSpace%
@echo Get Lastest Finished
@echo -------------------------

@echo Clear BinOutput
del %SolutionDir%\%BinOutput%\ /Q /S /F
@echo Clear Binoutput Finished
@echo -------------------------

@echo Building Start

call %MSBuildDir%\msbuild %SolutionPath% /t:Rebuild /p:Configuration=%BuildType% >> logs\NI.EAS.log

@echo Building Finsihed
@echo -------------------------

find "0 Error(s)" logs\NI.EAS.log && echo "no error" > logs\no_error.txt

if exist logs\no_error.txt (goto succeed) else (goto failed)

:succeed
call Deploy_Jobs.bat %SourceDir% %BuildType%

echo compile succeed

pause
exit

:failed
echo compile failed

pause
exit

------------------------------------------------------------------------------
4.Deploy_Jobs.bat

set SourceDir=%1
set BuildType=%2

set FinancialJobDir=%SourceDir%\AutoInterfaceTask\InterfaceTask\TaskService\bin\%BuildType%
set ScheduleJobDir=%SourceDir%\N-EAS\Jobs\NI.EAS.Jobs\bin\%BuildType%

set FinancialJobDestDir=D:\ServiceRun\Debug
set ScheduleJobDestDir=D:\Scheduler\bin\Release


@echo Backup the latest version
del bak_jobs\ /Q /S /F
xcopy %FinancialJobDestDir%\*.* bak_jobs\ServiceRun\ /S /Y /exclude:skipFiles.txt
xcopy %ScheduleJobDestDir%\*.* bak_jobs\Scheduler\ /S /Y /exclude:skipFiles.txt

@echo Copy to destination

rem net stop Finance

rem xcopy %FinancialJobDir%\*.* %FinancialJobDestDir%\ /S /D /Y /exclude:skipFiles.txt

rem net start Finance


net stop ERPSchedluer

xcopy %ScheduleJobDir%\*.* %ScheduleJobDestDir%\ /S /D /Y /exclude:skipFiles.txt

net start ERPSchedluer