clear
#获取代码最新版本
&'C:\Program Files\TortoiseSVN\bin\TortoiseProc.exe' /command:update /path:"D:\tujia\branches" /closeonend:1
if($?)
{
"获取最新版本成功"
}
#编译
&'C:\Windows\Microsoft.NET\Framework64\v4.0.30319\msbuild' D:\tujia\branches\Solution\All\All.sln /v:n
if(!$?)
{
"编译失败"
return 1
}
#获取当前脚本路径
$CurrentScriptPath = Split-Path -Parent $MyInvocation.MyCommand.Definition
#读取后台WCF服务器地址
$path = Join-Path $CurrentScriptPath "WcfServers.txt"
$wcfServers = Get-Content -Path $path
$WcfExcludeFile = Join-Path $CurrentScriptPath "WcfExclude.txt"
#复制Wcf服务网页和程序的文件
foreach($wcfServer in $wcfServers)
{
&'c:\Windows\System32\xcopy.exe' ("D:\Tujia\branches\Projects\TuJia.WCF.Account") ("\\" + $wcfServer + "\d$\web\WCF.Account") /e /y /r /s /EXCLUDE:$WcfExcludeFile
&'c:\Windows\System32\xcopy.exe' ("D:\Tujia\branches\Projects\TuJia.WCF.OrderManage") ("\\" + $wcfServer + "\d$\web\WCF.OrderManage") /e /y /r /s /EXCLUDE:$WcfExcludeFile
&'c:\Windows\System32\xcopy.exe' ("D:\Tujia\branches\Projects\TuJia.WCF.Product") ("\\" + $wcfServer + "\d$\web\WCF.Product") /e /y /r /s /EXCLUDE:$WcfExcludeFile
$wcfServer + "服务器的WCF部署完成!"
}
#读取web服务器地址
$path = Join-Path $CurrentScriptPath "WebServers.txt"
$WebServers = Get-Content -Path $path
$WebExcludeFile = Join-Path $CurrentScriptPath "WebExclude.txt"
#复制各Web的程序和网页文件
foreach($WebServer in $WebServers)
{
&'c:\Windows\System32\xcopy.exe' ("D:\Tujia\branches\Projects\TuJia.Web.BackOffice") ("\\" + $WebServer + "\d$\web\Web.BackOffice") /e /y /r /s /EXCLUDE:$WebExcludeFile
&'c:\Windows\System32\xcopy.exe' ("D:\Tujia\branches\Projects\TuJia.Web.ContentSite") ("\\" + $WebServer + "\d$\web\Web.ContentSite") /e /y /r /s /EXCLUDE:$WebExcludeFile
&'c:\Windows\System32\xcopy.exe' ("D:\Tujia\branches\Projects\TuJia.Web.HotelManage") ("\\" + $WebServer + "\d$\web\Web.HotelManage") /e /y /r /s /EXCLUDE:$WebExcludeFile
&'c:\Windows\System32\xcopy.exe' ("D:\Tujia\branches\Projects\TuJia.Web.OrderSystem") ("\\" + $WebServer + "\d$\web\Web.OrderSystem") /e /y /r /s /EXCLUDE:$WebExcludeFile
&'c:\Windows\System32\xcopy.exe' ("D:\Tujia\branches\Projects\TuJia.Web.Passport") ("\\" + $WebServer + "\d$\web\Web.Passport") /e /y /r /s /EXCLUDE:$WebExcludeFile
&'c:\Windows\System32\xcopy.exe' ("D:\Tujia\branches\Projects\TuJia.Web.PortalSite") ("\\" + $WebServer + "\d$\web\Web.PortalSite") /e /y /r /s /EXCLUDE:$WebExcludeFile
$WebServer + "服务器的Web部署完成!"
}
#部署静态内容
&'c:\Windows\System32\xcopy.exe' ("D:\Tujia\branches\Projects\TuJia.Web.StaticFile") ("\\test-web-02\d$\web\Web.StaticFile") /e /y /r /s /EXCLUDE:$WebExcludeFile
#重启产品搜索缓存服务器
$SearchUnitCacheServer = "\\test-cache-01"
"正在重启缓存服务"
&"c:\Windows\system32\sc.exe" $SearchUnitCacheServer stop "Memcachedserver11213"
&"c:\Windows\system32\sc.exe" $SearchUnitCacheServer start "Memcachedserver11213"
"重启缓存服务完成"
#重启登录信息缓存服务器(一般情况下不用)
#&"c:\Windows\system32\sc.exe" \\vmwebedit stop "Memcachedserver11212"
#&"c:\Windows\system32\sc.exe" \\vmwebedit start "Memcachedserver11212"
#停止相关的Windows服务
"正在停止Windows服务"
$BusinessEventServer = "\\test-web-01"
$ScheduleTaskServer = "\\test-web-01"
&"c:\Windows\system32\sc.exe" $BusinessEventServer stop "TuJia Business Event"
&"c:\Windows\system32\sc.exe" $ScheduleTaskServer stop "TuJia Schedule Task"
"已停止Windows服务,请等候60秒"
#空转60秒,确保Windows服务彻底停止
ping localhost -n 60 >> null
#复制Windows的程序文件
"正在部署Windows服务"
&'c:\Windows\System32\xcopy.exe' ("D:\tujia\branches\Projects\TuJia.WindowsService.BusinessEvent\bin\Debug") ($BusinessEventServer + "\d$\WindowService\TuJia.WindowsService.BusinessEvent") /e /y /r /s
&'c:\Windows\System32\xcopy.exe' ("D:\tujia\branches\Projects\TuJia.WindowsService.ScheduleTask\bin\Debug") ($ScheduleTaskServer + "\d$\WindowService\TuJia.WindowsService.ScheduleTask") /e /y /r /s
#启动Windows服务
"正在启动Windows服务"
&"c:\Windows\system32\sc.exe" $BusinessEventServer start "TuJia Business Event"
&"c:\Windows\system32\sc.exe" $ScheduleTaskServer start "TuJia Schedule Task"
"已启动Windows服务"