question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Escaped quotes in symbol parameter values lost or cause errors

See original GitHub issue

When I try to pass quotation marks to a parameter from the command line, I either get an error or the produced content will not contain quotation marks.

Full details can be found in my sample repo notes, but here are some examples.

dotnet new repro-quotes-spaces --someparameter="something needing `"escaped quotes`" in it."

Results in this error:

Invalid input switch:
  quotes in it.

If I remove the space within the quoted sub-string, there is no error, but the content it produces doesn’t have any quotation marks either.

dotnet new repro-quotes-spaces --someparameter="something needing `"escapedquotes`" (without spaces) in it."

Results in this text missing the expected quotes:

something needing escapedquotes (without spaces) in it.

Environment

  • Windows 10 Pro 1803 and macOS v10.13.6 (High Sierra)
  • .NET Core SDK: v2.1.500 (also tested on v2.1.302)
  • PowerShell Core: v6.1.0

Sample repro

Here is a repo containing a sample and my notes so far (Notes direct link):

https://github.com/patridge/repro-DotnetNewTemplateParameterQuotes

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
bekir-ozturkcommented, May 19, 2021

Hi @patridge, This issue will be resolved once we switch to the new command line parser which is planned for .NET 6. You can track the work here #2191.

0reactions
vlada-shubinacommented, Aug 16, 2022

Closing, this has been fixed in .NET 7. Correct syntax follows:

Command prompt

--someparameter="something needing \"escaped quotes\" in it." --someparameter="something needing ""escaped quotes"" in it."

PowerShell 7

--someparameter="something needing \`"escaped quotes\`" in it." --someparameter="something needing `"`"escaped quotes`"`" in it."

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to escape double quotes in JSON
Try this: "maingame": { "day1": { "text1": "Tag 1", "text2": "Heute startet unsere Rundreise \" Example text\".
Read more >
Struggling to deserialize JSON with escaped double quotes
I'll try to illustrate this. This is valid JSON. { "errors": [ { "params": { "password": "size must be between 4 and 30",...
Read more >
How to Handle the Unclosed String Literal Error in Java
Python unclosed string literal error refers to the Java compiler failing to interpret a string literal due to the missing of a double...
Read more >
apex - JSON and escaped double quote
As you can see here, the portion at the end of the Description value is ended with backslash double quote. If I attempt...
Read more >
Introduction to SQL Escape
This article will provide an introduction to SQL escape characters for using special characters and their characteristics.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found