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?
答案 0 :(得分:4)
经过多次挖掘(发布此问题后),我在ProjectName | Properties | PublishProfiles下找到了一个名为MyProjectName.pubxml的文件:
我找到了这一行:
<DebugSymbols>False</DebugSymbols>
将此设置为True后,它最终得到解决并按预期工作。我还注意到LastUsedBuildConfiguration
的值是Release,虽然它实际上是Debug。所以很明显这个文件在某些时候不能是最新的。希望这有助于那些候选人浪费数小时的时间。
修改强>
我再次面临同样的问题,但这次我需要反向发布模式。这次更改上述文件并没有解决问题。所以我决定做我认为最好的事情:只需删除PublishProfiles文件夹,以便在下次尝试发布应用程序时提示您创建新的发布配置文件。这解决了这个问题。
<强> EDIT2 强>
伙计,我没有意识到有选择配置的选项。出来我们需要选择我们需要发布的配置,无论在visual studio本身选择什么配置。