[英]Visual Studio 2013 DEBUG preprocessor directive always defined
I added a new project to a Visual Studio 2013 (12.0.40629.00 Update 5) solution, and suddenly the #if DEBUG
checks pass for compiled code, even in release.我在 Visual Studio 2013 (12.0.40629.00 Update 5) 解决方案中添加了一个新项目,突然#if DEBUG
检查通过编译代码,即使在发布中也是如此。 The 'define DEBUG constant' is disabled for the release build, and all projects are built as release (as seen in the configuration manager).发布版本禁用了“定义调试常量”,所有项目都构建为发布版本(如配置管理器中所示)。
I find several things on Google that this is a known bug that can be worked around by unloading and reloading the project (like here , but that doesn't help).我在 Google 上发现几件事情,这是一个已知的错误,可以通过卸载和重新加载项目来解决(就像这里,但这无济于事)。
I also tried undef DEBUG
, but also no luck.我也试过undef DEBUG
,但也没有运气。
Existing projects in the solution works, but this new one doesn't.解决方案中的现有项目有效,但这个新项目无效。 It's a Dotnet standard 4.5, but setting it to 3.5 doesn't help.它是 Dotnet 标准 4.5,但将其设置为 3.5 无济于事。
As an indication of what happens in a release build:作为发布版本中发生的事情的指示:
Visual studio thinks it's inactive code, but it's obviously compiled in and executed (and debugged). Visual Studio 认为它是非活动代码,但它显然已编译并执行(和调试)。
This makes it impossible to make release builds.这使得发布版本变得不可能。
Edit: to elaborate on the question below: it's not a unit test, but I am starting to suspect that debug DLLs are taken.编辑:详细说明以下问题:这不是单元测试,但我开始怀疑是否采用了调试 DLL。 To be able to release, I quickly deleted all the code in #if DEBUG
, and even after compiling that, the software tried to open the debug DB.为了能够发布,我迅速删除了#if DEBUG
所有代码,即使在编译之后,软件也试图打开调试数据库。 When I recompiled debug, it was OK.当我重新编译调试时,就可以了。
I ran into this again.我又遇到了这个。 I don't know how I did it, but apparently I added references as links to debug DLL's, instead of to projects in the solution.我不知道我是怎么做到的,但显然我添加了引用作为调试 DLL 的链接,而不是解决方案中的项目。
This diff of a csproj
explains it:这个csproj
差异解释了它:
- <Reference Include="Bla.Utils">
- <HintPath>..\BlaUtillLib\obj\Debug\Bla.Utils.dll</HintPath>
- </Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data.Entity" />
@@ -166,12 +163,19 @@
<Project>{e2bec86c-1c02-4182-8117-740612ed9330}</Project>
<Name>DbDAL</Name>
</ProjectReference>
+ <ProjectReference Include="..\BlaUtillLib\Bla.Utils.csproj">
+ <Project>{6de20344-62f7-45f7-92cd-dbeb19cdc4c5}</Project>
+ <Name>Bla.Utils</Name>
+ </ProjectReference>
I don't know how this happens.我不知道这是怎么发生的。 I don't go out of my way to browse to DLL's of the solution's own projects.我不会特意浏览解决方案自己项目的 DLL。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.