如何在 github 工作流程中 运行 带空格的命令

How do I run a command with spaces in a github workflow

我需要为 github workflow 中的 Visual Studio 代码安装扩展。我想在工作流程中 运行 这个命令:

run: C:/Program Files/Microsoft VS Code/code.exe --install-extension ms-dynamics-smb.al

然而github运行人不喜欢这样:

Run C:\Program Files\Microsoft VS Code\code.exe --install-extension ms-dynamics-smb.al
C:\Program: D:\a\_temp\e14dee42-ae33-48ac-ad4e-44f4e4600de5.ps1:2
Line |
   2 |  C:\Program Files\Microsoft VS Code\code.exe --install-extension ms-dy …
     |  ~~~~~~~~~~
     | The term 'C:\Program' is not recognized as a name of a cmdlet, function, script file, or executable
     | program. Check the spelling of the name, or if a path was included, verify that the path is correct
     | and try again.

我尝试了以下变体,但都失败了:

run "C:\Program Files\Microsoft VS Code\code.exe --install-extension ms-dynamics-smb.al"
--> Invalid workflow file

run "C:/Program Files/Microsoft VS Code/code.exe --install-extension ms-dynamics-smb.al"
--> The term 'C:/Program' is not recognized as a name of a cmdlet...

run 'C:/Program Files/Microsoft VS Code/code.exe --install-extension ms-dynamics-smb.al'
--> The term 'C:/Program' is not recognized as a name of a cmdlet...

run \"C:/Program Files/Microsoft VS Code/code.exe\" --install-extension ms-dynamics-smb.al
--> The term '\C:/Program Files/Microsoft VS Code/code.exe\' is not recognized...

如何在 github 工作流文件中正确 handle/escape 带空格的路径?

怎么样

run: |
  "C:/Program Files/Microsoft VS Code/code.exe" --install-extension ms-dynamics-smb.al

所以你使用 YAML 块而不是引用单词?