我需要在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工作流文件中带有空格的路径?
2条答案
按热度按时间slwdgvem1#
不如
所以您使用了YAML块而不是引用单词?
oymdgrw72#
AKX所提出的与最终的结果很接近,我在我的build. yaml中有三个错误
C:/Program Files/Microsoft VS Code/bin/code.cmd
&
,否则powershell只会把它解释为一个字符串并返回它。这是解决方案:
我想把这个作为对AKX答案的编辑发布,但是SO评论者拒绝了我的编辑,并建议作为单独的答案发布。我保留了AKX的答案作为可接受的答案,因为他让我走上了正确的轨道。