Search code examples
c#visual-studiocompiler-directives

Visual Studio C# Project Template #if DEBUG #endif disappear in produced projects


I have Visual Studio C# project template with #if DEBUG #endif directives like this:

#if DEBUG
...
#endif

But when I creating project from this template it doesn't contain this part. Can I somehow make it to be in projects that created from this template?


Solution

  • Please follow this tutorial to create a template.

    My test environment: vs 2022 17.4.1 C# .Net 6.0

    The template created by Export Template can correctly create what you want when added.

    enter image description here

    Demo:

    enter image description here