Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DEBUG defined when publishing

I have a strange issue

#if (!DEBUG)
    checkLicense();
#endif

This is working correctly in both Release and Debug configurations. But when I try to publish using release configuration this condition does not execute. It looks like publish is using the debug dll.

What have I missed?

like image 412
Sanja Melnichuk Avatar asked Oct 21 '22 15:10

Sanja Melnichuk


1 Answers

There is a setting to control whether the DEBUG constant is defined for each project based on the different deployment modes. See this answer to verify that the constant is being defined for 'release mode' by making sure the Define DEBUG constant checkbox is checked.

If the box isn't checked, then your debug code is being removed by the preprocessor before compiling your site and no code will execute, even if you include the ELSE as the other answer suggested.

If that doesn't work, then another possibility is be that the machine you're running your release code on could have its machine.config with the deployment element:

<deployment retail="true" />

This element overrides the web.config setting for your application and sets the debug flag to false for all .NET applications on the machine.

So if possible, check that. Although I think the first option I gave you is much more likely.

like image 162
Ryan Weir Avatar answered Oct 27 '22 09:10

Ryan Weir