pass parameters to batch file in msdeploy runcommand

那年仲夏 提交于 2019-11-28 08:13:12

问题


I am not able to get this to work

call "%MSDeployPath%msdeploy" -verb:sync -source:runCommand='backup.bat param1' -dest:auto,computername=10.xx.xx.xx,username=xxx,password=yyy

It gives me:

Warning: 'backup.bat' is not recognized as an internal or external command, operable program or batch file.

Warning: The process 'C:\Windows\system32\cmd.exe' (command line '') exited with code '0x1'. Total changes: 1 (0 added, 0 deleted, 1 updated, 0 parameters changed, 0 bytes copied)

If I remove the param1 and hardcode it inside the .bat, it works, so there's no problem with the bat file, in case you wonder.

I tried to specify the full path to .bat and it still doesn't work:

call "%MSDeployPath%msdeploy" -verb:sync -source:runCommand='c:\backup.bat param1' -dest:auto,computername=10.xx.xx.xx,username=xxx,password=yyy

In this case, it looks like it interprets the path as a remote path, it expects backup.bat to be on the server. This was confirmed to me after I moved backup.bat on the server, it worked

WHY does it have to be so HARD???


回答1:


Edit You are right, the documentation states that cmd/bat files will be streamed to the destination.

It seems to me that it's simply a limitation of the feature that it can't accept arguments. It shouldn't be too difficult to create a modified version of the batch file at deploy-time with the settings hardcoded.

Something like:

REM Start of prepended script
SET SCRIPT_USERNAME=ThatGuy
REM End of prepended script

IF ("%SCRIPT_USERNAME%" == "") SET SCRIPT_USERNAME=%1

Update Having browsed the reflected source (ahem) of msdeploy, I can confirm that it's simply the way it's current designed. It determines whether to upload the file based on whether the entire path represents a file. Since adding arguments will prevent it resolving the path to a file, it doesn't upload anything.



来源:https://stackoverflow.com/questions/12672893/pass-parameters-to-batch-file-in-msdeploy-runcommand

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!