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

110 views Asked by At

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?

1

There are 1 answers

2
Jiale Xue - MSFT On BEST ANSWER

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