简体   繁体   English

在 arguments 中为 Visual Studio Pro 2019 传递空格

[英]Passing spaces in arguments for Visual Studio Pro 2019

I am trying to debug a command line program inside Visual Studio.我正在尝试在 Visual Studio 中调试命令行程序。 I am sharing my configuration with another machine using Box.我正在使用 Box 与另一台机器共享我的配置。 The paths I am passing have spaces in them and I haven't been successful in escaping the spaces so that instead of 3 arguments I get 9. This is the relevant section from the original launch.vs.json .我通过的路径中有空格,我在 escaping 中没有成功,所以我得到 9 而不是 3 arguments。这是原始launch.vs.json的相关部分。

{
  "type": "default",
  "project": "CMakeLists.txt",
  "projectTarget": "dispatcher.exe (src\\dispatcher\\dispatcher.exe)",
  "name": "dispatcher.exe (src\\dispatcher\\dispatcher.exe)",
  "args": [
    "C:\\Users\\212434537\\Box Sync\\Edge Agent\\srasku-windows.json",
    "C:\\Users\\212434537\\Box Sync\\Edge Agent\\static.json",
    "C:\\Users\\212434537\\Box Sync\\Edge Agent\\dynamic.json"
  ]
}

None of these work.这些都不起作用。

"\"C:\\Users\\212434537\\Box Sync\\Edge Agent\\srasku-windows.json\""
"\\"C:\\Users\\212434537\\Box Sync\\Edge Agent\\srasku-windows.json\\""
"\\\"C:\\Users\\212434537\\Box Sync\\Edge Agent\\srasku-windows.json\\\""
"\\\\"C:\\Users\\212434537\\Box Sync\\Edge Agent\\srasku-windows.json\\\\""

How can I escape my spaces so that each argument is passed as a single argument instead of three.我怎样才能转义我的空间,以便每个参数作为单个参数而不是三个参数传递。 Note: I saw this question but it didn't solve my problem.注意:我看到了这个问题,但它并没有解决我的问题。

It turns out you need to surround the spaces with singly-escaped double-quotes:事实证明,您需要用单转义双引号将空格括起来:

Here is the resultant section:这是结果部分:

   {
      "type": "default",
      "project": "CMakeLists.txt",
      "projectTarget": "dispatcher.exe (src\\dispatcher\\dispatcher.exe)",
      "name": "dispatcher.exe (src\\dispatcher\\dispatcher.exe)",
      "currentDir": "C:\\Users\\212434537\\source\\Edge-Agent",
      "args": [
        "C:\\Users\\212434537\\Box\" \"Sync\\Edge\" \"Agent\\srasku-windows.json",
        "C:\\Users\\212434537\\Box\" \"Sync\\Edge\" \"Agent\\static.json",
        "C:\\Users\\212434537\\Box\" \"Sync\\Edge\" \"Agent\\dynamic.json"
      ]
    }

A simple workaround for this, is just to include the entire path in quotes, such as:一个简单的解决方法是将整个路径包含在引号中,例如:

"C:\Users\212434537\Box Sync\Edge Agent\dynamic.json"

So, the escaped json becomes:因此,转义后的 json 变为:

"\"C:\\Users\\212434537\\Box Sync\\Edge Agent\\dynamic.json\""

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 Visual Studio Pro 2019 中设置 JSON 文本编辑器选项卡/空格设置? - How do I setup JSON Text Editor Tabs/Spaces settings in Visual Studio Pro 2019? 用于 Dotnetcore 函数的 Visual Studio 2019 应用程序参数 - Visual Studio 2019 Application Arguments for Dotnetcore function Visual Studio Pro 2019 16.8.4 - 脚本任务编辑器未在 SSIS 中打开 - Visual Studio Pro 2019 16.8.4 - Script Task Editor Not Opening in SSIS 使用 Visual Studio Pro 2019 对 Node.js/TS 进行性能分析 - Performance profiling Node.js/TS with Visual Studio Pro 2019 在 Visual Studio 2019 中将 ArcGIS Pro SDK 用于 .NET 的问题 - Problem with using ArcGIS Pro SDK for .NET in Visual Studio 2019 如何防止 Visual Studio 2019 将制表符更改为空格? - How to prevent Visual Studio 2019 from changing tabs to spaces? Visual Studio 2019 在应使用空格时在 Enter 时插入制表符 - Visual Studio 2019 is inserting tabs on enter when it should be using spaces 在 Visual Studio 2010 中传递命令行 arguments? - Passing command line arguments in Visual Studio 2010? 如何在 Visual Studio 代码 2019 中获取位置 arguments 名称 - How to get positional arguments name in visual studio code 2019 为什么我的 Visual Studio 2019 Pro 在进行 Visual Installer 更新后调试如此缓慢? - why is my Visual Studio 2019 Pro so slow debugging, after doing Visual Installer update?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM