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

Viewed 549

I need to install an extension for Visual Studio Code in a github workflow. I want to run this command in the workflow:

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

However, the github runner does not like this:

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.

I tried the following variations, but everything fails:

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...

How do I properly handle/escape a path with spaces in a github workflow file?

1 Answers

How about

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

so you use a YAML block instead of quoting words?

Related