1、把需要更新文件放入指定文件夹:如Publish-Demo
2、新建 app_offline.htm文件、用作临时替换页
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>站点更新中</title> </head> <style> div { background-color: #7DBBDA; padding-top: 10px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; border-style: solid; border-color: Black; border-width: 1px; } </style> <body> <div> <h1>站点更新中</h1> <p>站点更新中,请稍后访问。</p> </div> </body> </html>
3、新建bat,执行部署操作
@echo off set publish_path= D:WebSitePublish-Demo set pool_name=Publish-Demo set update_filename=Publish-Demo set bak_path= %publish_path%-%date:~0,4%%date:~5,2%%date:~8,2%%time:~0,2%%time:~3,2%%time:~6,2% echo 停止“应用程序池” C:WindowsSystem32inetsrvappcmd.exe stop apppool /apppool.name:%pool_name% xcopy %publish_path% %bak_path% /s /q xcopy %cd%app_offline.htm %publish_path% /q xcopy %cd%\%update_filename% %publish_path% /s /q /y /i del %publish_path%app_offline.htm echo 启动“应用程序池” C:WindowsSystem32inetsrvappcmd.exe start apppool /apppool.name:%pool_name% pause & exit
注:以下需根据需求修改
publish_path 网站发布目录
pool_name 网站所使用应用池名称
update_filename 更新文件目录名称
4、双击bat文件,完成更新发布