【问题标题】:Using visual studio code and running tasks where path to .exe contains a space使用 Visual Studio 代码并运行 .exe 路径包含空格的任务
【发布时间】:2018-07-08 20:46:44
【问题描述】:

我正在按照microsoft docs 的演练在 vs 代码项目中使用 typescript。当我尝试运行构建任务时,终端会出现

执行任务:c:\whatever\my path with spaces\Projects\ProjectName\node_modules.bin\tsc.cmd -p "c:\whatever\my path with spaces\Projects\ProjectName\tsconfig.json"

和错误

'c:\whatever\my' 未被识别为内部或外部命令,

也就是说,文件夹名称中的空格使任务运行者感到困惑。我需要类似的东西

call "c:\whatever\my path with spaces\Projects\ProjectName\node_modules\.bin\tsc.cmd" -p "c:\whatever\my path with spaces\Projects\ProjectName\tsconfig.json"

如何设置 VS Code 以便终端接收可以用目录名称中的空格解释的输入?谢谢

当前任务.json:

"version": "2.0.0",
"tasks": [
    {
        "type": "typescript",
        "tsconfig": "tsconfig.json",
        "problemMatcher": [
            "$tsc"
        ],
        "group": {
            "kind": "build",
            "isDefault": true
        }
    }
]

【问题讨论】:

标签: visual-studio-code


【解决方案1】:

你应该在整个命令中使用引号\"(斜线+引号)

"command": "\"c:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe\"",

【讨论】:

    【解决方案2】:

    尝试使用 ''-s 转义包含空格的字符串:

    • 在终端:c:\whatever\'my path with 空格'\Projects\ProjectName\tsconfig.json
    • 在 .json 中:“命令”: "c:\\whatever\\'我的路径 空格'\\Projects\\ProjectName\\tsconfig.json"

    【讨论】:

      猜你喜欢
      • 2016-07-07
      • 1970-01-01
      • 1970-01-01
      • 2020-12-22
      • 2013-09-18
      • 2011-04-06
      • 2014-11-16
      • 2021-05-07
      • 2012-11-02
      相关资源
      最近更新 更多