dotnet / dotnet/project-system

Unable to use quotes in launchSettings.json

Open
#9,157 6 comments 0 reactions 1 assignee Claimed by @adamint View on GitHub
Feature-Debugging Triage-Approved
Dominant language
C#
Stars
1k
Forks
415
PR merge metrics
No merged PRs in 30d

Description

## Visual Studio Version

Version 17.8.0 Preview 1.0 [33909.54.main]

## Summary

As part of the debug sequence I need to pass a variable to a script, and that variable may contain spaces, so it needs to be quoted for the script to correctly interpret the cli argument.

```json
{
"profiles": {
"Launch test VS": {
"commandName": "Executable",
"executablePath": "$(SolutionDir)\\start-debug.cmd",
"commandLineArgs": "$(ExtensionsTestVSPath)\\Common7\\IDE\\devenv.exe"
}
}
}
```

where `$(ExtensionsTestVSPath)` is expanded to `C:\Program Files\Microsoft Visual Studio\2022\PublicPreview\Common7\IDE\devenv.exe`.

```cmd
:: start-debug.cmd

@ECHO OFF

:: Chane to the scripts directory
cd %~dp0

echo %1
pause
exit 0
```

![image](https://github.com/dotnet/project-system/assets/4403806/2a5fc1f8-c043-4bb0-bc80-3f0b3856a854)

I tried `'"$(ExtensionsTestVSPath)\\Common7\\IDE\\devenv.exe"'`, and VS didn't like it. I also tried `"\"$(ExtensionsTestVSPath)\\Common7\\IDE\\devenv.exe\""`, and VS didn't like it either.
I tried silly things like `""e;$(ExtensionsTestVSPath)\\Common7\\IDE\\devenv.exe"e;"` but that didn't work either...

## Expected Behavior

How can I quote the cli argument?

## User Impact

This is pretty much blocking in a general case.
I had to resort to reading the whole command line and treat it as a single argument (i.e., `%*`), but this only works in a scenarios where I have a single argument to pass to a script. If I need more than one argument to pass - there's no way.

## Repro

[9157.zip](https://github.com/dotnet/project-system/files/12066269/9157.zip)

https://github.com/dotnet/project-system/assets/4403806/44e211e0-61b5-4473-8746-2aacd3593856

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.