自更新(从 SVN)Powershell 脚本的最佳方式是什么?
它应该能够启动一个新进程,然后调用SVN update $script; './$script'
,在确保当前进程已结束后。
if ((svn st -u --quiet $script) -match "\*"){
$scriptToRun = 'SVN update $script; "./$script"'
##start new process that will end this process and execute $scriptToRun
}
最佳答案
我认为这可以解决问题,即使有点天真。您有两个脚本 - StartApp.ps1
,它们对更新进行任何必要的检查。运行后,然后链接 MainApp.ps1
这是应用程序本身,这就是要更新的内容。
StartApp.ps1 - 启动应用程序,但也会进行更新检查:
# Bootstrap app
#
# Check for updates here
if(some_check_to_determine_if_update_required)
{
# Execute whatever external source control commands required but wait until
# done:
Start-Process -Wait -FilePath "<path_to_svn>" -ArgumentList <args_you_need>
}
# Launch the (now possibly updated) app
.\MainApp.ps1
关于svn - 自动更新Powershell脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5637362/