Reputation: 12367
There're places where I use #if DEBUG
compiler directive to choose which code to compile. Until just a little while ago I was able to publish my ASP.NET MVC application in either Debug or Release mode. In fact I can still do that. But now, for some reason, no matter which mode I choose I get only the Release code in the output. If I take a look inside the generated dll with .NET Reflector, I can see that the code after #if DEBUG
is not present.
I've checked the Define DEBUG constant
for Debug mode in project properties. The only way I can get it work is to define DEBUG constant explicitly. Is there any other place where I can configure publish settings besides the one when publishing?
Upvotes: 1
Views: 1621
Reputation: 12367
After lot's of digging (and right after posting this question), I found a file called MyProjectName.pubxml under ProjectName|Properties|PublishProfiles:
There I found this line:
<DebugSymbols>False</DebugSymbols>
After setting this to True, it finally got solved and works as expected. I also noticed that the value for LastUsedBuildConfiguration
was Release although it was Debug in fact.So obviously this file failed to be up-to-date at some point. Hope this helps those who are candidates to waste hours of time in time.
EDIT
I faced the same problem again but this time I needed the reverse, the publish mode. Changing the above mentioned file didn't solve the problem this time. So I decided to do what I think would be the best thing to do: Just remove the PublishProfiles folder so that you are prompted to create a new publish profile when you try to publish your application the next time. That solved the problem.
EDIT2
Man, I didn't realize that there was an option to choose a configuration. Comes out we need to choose which configuration we need to publish to no matter what configuration is chosen in the visual studio itself.
Upvotes: 5