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.

Document how to escape a Condition

See original GitHub issue

Back in the .NET Core 1.1 release I was able to do this in my csproj to conditionally add things:

<Project Sdk="Microsoft.NET.Sdk.Web">
<!--#if (AuthoringMode)-->
  <PropertyGroup>
    <DefineConstants>$(DefineConstants);Swagger</DefineConstants>
  </PropertyGroup>
  <ItemGroup>
    <Content Include=".template.config\**\*" />
  </ItemGroup>
  <!--#endif-->

<ItemGroup Label="Package References">
    <PackageReference Include="Boilerplate.AspNetCore.Swagger" Version="3.0.0" Condition="'$(Swagger)' == 'true'" />
</ItemGroup>
</Project>

The Condition="'$(Swagger)' == 'true'" syntax gives compile time errors in .NET Core 2.0. I discovered somewhere that I can use the following syntaxinstead:

<PackageReference Include="Boilerplate.AspNetCore.Swagger" Version="3.0.0" Condition="$(DefineConstants.Contains('Swagger'))" />

This syntax compiles but no longer works with dotnet new. Is there a solution to this problem? Should I also be using #if comment syntax like this:

<!--#if (Swagger)-->
<PackageReference Include="Boilerplate.AspNetCore.Swagger" Version="3.0.0" Condition="$(DefineConstants.Contains('Swagger'))" />
<!--#endif-->

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
vlada-shubinacommented, Oct 19, 2020

Closing item - the wiki article was updated.

1reaction
giggiocommented, Sep 21, 2020

@RehanSaeed I see PR #2527 but it is not yet merged, why was this issue closed early?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to properly escape the content of a <code> example ...
In this example below, Intellisense highlights the > character because I need to escape it, it says the code will not be included...
Read more >
escape() - JavaScript - MDN Web Docs - Mozilla
The escape() function computes a new string in which certain characters have been replaced by hexadecimal escape sequences.
Read more >
ESCAPE clause in LIKE operator - Progress Documentation
The ESCAPE clause is supported in the LIKE operator to indicate the escape character. Escape characters are used in the pattern string to...
Read more >
ESCAPE
The ESCAPE statement is used to interrupt the linear flow of execution of a processing loop or a routine. With the keywords TOP...
Read more >
Escape Sequences
Escape sequences are typically used to specify actions such as carriage returns and tab movements on terminals and printers. They are also used ......
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