[英]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.