Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Publish in debug mode but compiler removes code inside #if debug

I'm only publishing in debug mode to test on my local machine and I was hoping the '#if debug' mode would work so that I could test features that I don't want in production yet.

When I publish in debug mode the web.config still has

<system.web>
    <compilation debug="true" targetFramework="4.0">
</system.web>

but when I use reflector on the project's dll the code that was like this

#if debug
    PlaceHolder1.Visible = true;
#endif

is non-existent. I figure the compiler has removed it.

NOTE: I'm NOT talking about a build, I'm talking about publishing. Doing a debug build works as I expect it to with the code above still present

Is this expected behavior? Is there a way to get the compiler to include those bits of code when I'm publishing in debug mode? Am I going about this all wrong?

Update: In response to @dash's comment my Package/Publish Web settings are:

Package/Publish Web settings

like image 540
Dean Avatar asked Nov 19 '25 06:11

Dean


1 Answers

C# preprocessor symbols are case-sensitive. Try:

#if DEBUG
like image 129
Nick Butler Avatar answered Nov 20 '25 21:11

Nick Butler



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!