从调试版本中检测发布版本的最佳方法? 。净 [英] Best way to detect a release build from a debug build? .net

查看:96
本文介绍了从调试版本中检测发布版本的最佳方法? 。净的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有大约10个短的css文件,我使用的mvc应用程序。

error.css
login.css
等...
只是一些真正的短css文件,使更新和编辑变得容易(至少对我来说)。我想要的是将优化if else分支,而不是将其并入最终位。我想做这样的事情

  if(Debug.Mode){

< link rel =stylesheettype =text / csshref =error.css/>
< link rel =stylesheettype =text / csshref =login.css/>
< link rel =stylesheettype =text / csshref =menu.css/>
< link rel =stylesheettype =text / csshref =page.css/>
} else {
< link rel =stylesheettype =text / csshref =site.css/>
}

我将有一个msbuild任务将组合所有的CSS文件,最小化他们和所有那些好东西。我只需要知道是否有办法在最后的位中删除if else分支。

解决方案

具体来说,就像这样在C#中:

  #if(DEBUG)
调试东西
#endif

C#具有以下预处理指令:

  #if 
#else
#elif //否如果
#endif
#define
#undef // Undefine
#warning / /导致预处理器触发警告
#error //导致预处理器触发致命错误
#line //让预处理程序知道这个源代码行来自
#region // Codefolding
#endregion


So I have about 10 short css files that I use with mvc app. There are like error.css login.css etc... Just some really short css files that make updating and editing easy (At least for me). What I want is something that will optimize the if else branch and not incorporate it within the final bits. I want to do something like this

if(Debug.Mode){

<link rel="stylesheet" type="text/css" href="error.css" /> 
<link rel="stylesheet" type="text/css" href="login.css" /> 
<link rel="stylesheet" type="text/css" href="menu.css" /> 
<link rel="stylesheet" type="text/css" href="page.css" /> 
} else {
<link rel="stylesheet" type="text/css" href="site.css" /> 
}

I'll have a msbuild task that will combine all the css files, minimize them and all that good stuff. I just need to know if there is a way to remove the if else branch in the final bits.

解决方案

Specifically, like this in C#:

#if (DEBUG)
   Debug Stuff
#endif

C# has the following preprocessor directives:

#if 
#else 
#elif // Else If
#endif
#define
#undef // Undefine
#warning // Causes the preprocessor to fire warning
#error // Causes the preprocessor to fire a fatal error
#line // Lets the preprocessor know where this source line came from
#region // Codefolding
#endregion 

这篇关于从调试版本中检测发布版本的最佳方法? 。净的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆