What is up with this PowerShell command line quoting/escaping?

后端 未结 3 571
别跟我提以往
别跟我提以往 2021-02-13 20:40

I obviously don\'t know what I\'m doing.

I have finally got this PowerShell command to work. But I can\'t figure out why it works.

My concern is the final \"\" c

3条回答
  •  北荒
    北荒 (楼主)
    2021-02-13 20:55

    One of the areas at fault here is the inability of PowerShell to cope with the translation of the whitespace between "Program Files" expressed in the cmd-based msdeploy.

    This is an extremely basic solution and leverages antiquated DOS limitations, but the following non-whitespace references can be used in their stead:

    \Program Files\ ... \Progra~1\
    \Program Files (x86)\ ... \Progra~2\
    

    It's lame, but it works.

    You can also create a function that calls cmd and executes your command. This example also assumes what you're trying to call (msdeploy, etc.) is in the path.

    function PushToTarget() {
         cmd.exe /C $("msdeploy.exe -verb:sync -source:apphostconfig=yourwebapp-dev -dest:archivedir=d:\backup")
    }
    

提交回复
热议问题