PowerShell脚本更新svn且编译vs解决方案

主要是为了方便工作

 



# 这是函数程序
# 刷新服务,svn更新-杀进程-重编译-再启动
# 以下是参数参考
#$main_path = "F:\work\code" # 主目录
#$solution_path = "TestService" # 解决方案目录
#$solution_file = "TestService.sln" # 解决方案名
#$host_path = "TestService.host" # 解决方案执行程序项目目录
#$host_exe = "TestService.Host" # 解决方案执行程序名字,不带exe



function re_svn_kill_build_start($main_path,$solution_path,$solution_file,$host_path,$host_exe)
{
  $svn_home = "D:\TortoiseSVN\bin"
  $svn_exe = "$svn_home\TortoiseProc.exe"
  $full_solution_path = "$main_path\$solution_path"
  # 更新svn
  & $svn_exe /command:update /path:"$main_path\$solution_path" /notempfile /closeonend:1
  # 这里杀掉进程,如果是有这个进程
  if($host_exe -ne “”){
    Stop-Process -Name "$host_exe" -Force
    }
  # 用vs重新编译项目
  devenv /rebuild Debug "$full_solution_path\$solution_file"
  # 启动项目
  if($host_exe -ne “”){
    Start-Process -FilePath "$full_solution_path\$host_path\bin\Debug\$host_exe.exe"
    }
} 

# 测试样本,无需杀掉和启动进程就可以把最后一个参数 设置为空字符串
#re_svn_kill_build_start $main_path $solution_path $solution_file $host_path $host_exe


# ---------------------------以下是引用代码,在另一个ps1文件内
# 刷新5大进程,svn更新-杀进程-重新编译-再启动
# 引用上面的脚本文件,就能引用上面的函数了
. ("F:\work\code\public_func.ps1")

$main_path = "F:\work\code"

# 定义参数
$sol_array = @(
    @("Service1","Service1.sln","Service1.Host",""),
    @("Service2","Service2.sln","Service2.Host",""))
# 循环执行
$array_count = $sol_array.count
for($i=0; $i -lt $array_count; $i++)
{
    $curr_sol = $sol_array[$i]
    re_svn_kill_build_start $main_path $curr_sol[0] $curr_sol[1] $curr_sol[2] $curr_sol[3] 
}

 

转载于:https://my.oschina.net/raddleoj/blog/897199

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值