如何在deploy.cmd中使用-enableRule:AppOffline?

时间:2018-03-28 16:05:55

标签: asp.net asp.net-mvc windows iis webdeploy

我创建包:

msbuild myapp.csproj /T:Package /p:PublishProfile=myprofile;PackageLocation=mypackage.zip

尝试部署:

mypackage.deploy.cmd /Y -allowUntrusted /U:user /P:pass /M:myserver -enableRule:AppOffline

-enableRule:AppOffline完全被忽略,我没有错误。我也试过-enableRule:AppOfflineblahblahblah和同样的事情,所以它甚至没有试图验证这个论点。

我想使用该脚本,因此我不必手动构建webdeploy命令,但如何让-enableRule:AppOffline工作?

编辑: 这是它生成并运行的msdeploy命令:

msdeploy.exe -source:package='mypackage.zip' -dest:auto,computerName="myserver",userName="****",password="****",includeAcls="False" -verb:sync -disableLink:AppPoolExtension -disableLink:ContentExtension -disableLink:CertificateExtension -setParamFile:"C:\....\myapp\mypackage.SetParameters.xml"  -allowUntrusted -enableRule:AppOffline

所以我错了,看起来它正在向webdeploy添加arg而webdeploy是忽略它的那个。

我知道它被忽略了,因为我看到了这个错误:

....
Error Code: ERROR_FILE_IN_USE
More Information: Web Deploy cannot modify the file 'u_extend1_x.log' on the destination because it is locked by an external process.  In order to allow the publish operation to succeed, you may need to either restart your application to release the lock, or use the AppOffline rule handler for .Net applications on your next publish attempt. ....

1 个答案:

答案 0 :(得分:0)

您可以像这样运行

"C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" -verb:sync -source:package='C:\vstsagent\A1\_work\r1\a\temp_web_package_4846182484981034.zip' -dest:auto -setParam:name='IIS Web Application Name',value='site/appname' -enableRule:AppOffline

我运行.exe而不是.cmd版本,它也调用.exe版本。 .cmd版本是具有预定义部署参数的命令行文件。据我所见,在文件的来源。要添加所需的参数,您必须更改生成的文件。