Creating a Visual Studio project template, I need to use the $solutiondirectory$
parameter in the "commandLineArgs of a launchSettings.json file. $solutiondirectory$
return a string with single backslashes but json requires double (escaped) back slashes.
Typically, $solutiondirectory$
contains:
C:\Users\username\source\repos\Acad2025Plugin
.
How can I escape the single backslashes in the string returned by $solutiondirectory$
to get:
C:\\Users\\username\\source\\repos\\Acad2025Plugin
?
The template is based on this one, but I want to avoid the template being dependant to the LEGACYCODESEARCH sysvar settings by using full paths.
The launchSetting json file with a wrong "commandLineArgs" value (C:\Users\username\source\repos\Acad2025Plugin\\Acad2025Plugin\\start.scr
):
{
"profiles": {
"$projectname$": {
"commandName": "Executable",
"executablePath": "C:\\Program Files\\Autodesk\\AutoCAD 2025\\acad.exe",
"commandLineArgs": "/nologo /b \"$solutiondirectory$\\$projectname$\\start.scr\""
}
}
}
Creating a Visual Studio project template, I need to use the $solutiondirectory$
parameter in the "commandLineArgs of a launchSettings.json file. $solutiondirectory$
return a string with single backslashes but json requires double (escaped) back slashes.
Typically, $solutiondirectory$
contains:
C:\Users\username\source\repos\Acad2025Plugin
.
How can I escape the single backslashes in the string returned by $solutiondirectory$
to get:
C:\\Users\\username\\source\\repos\\Acad2025Plugin
?
The template is based on this one, but I want to avoid the template being dependant to the LEGACYCODESEARCH sysvar settings by using full paths.
The launchSetting json file with a wrong "commandLineArgs" value (C:\Users\username\source\repos\Acad2025Plugin\\Acad2025Plugin\\start.scr
):
{
"profiles": {
"$projectname$": {
"commandName": "Executable",
"executablePath": "C:\\Program Files\\Autodesk\\AutoCAD 2025\\acad.exe",
"commandLineArgs": "/nologo /b \"$solutiondirectory$\\$projectname$\\start.scr\""
}
}
}
Share
Improve this question
edited Mar 25 at 12:34
gileCAD
asked Mar 16 at 19:30
gileCADgileCAD
2,5132 gold badges12 silver badges12 bronze badges
1 Answer
Reset to default 0Just escape each backslash with a slash...
{...
"commandLineArgs": "/nologo /b \"$solutiondirectory$/\/\$projectname$/\/\start.scr/\""
...}