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

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

问题描述

所以我有大约 10 个用于 mvc 应用程序的短 css 文件.有像错误.css登录.css等等...只是一些非常短的 css 文件,使更新和编辑变得容易(至少对我而言).我想要的是可以优化 if else 分支而不是将其合并到最终位的东西.我想做这样的事情

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" /> 
}

我将有一个 msbuild 任务,它将合并所有 css 文件,将它们最小化以及所有好东西.我只需要知道是否有办法删除最后位中的 if else 分支.

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.

推荐答案

具体来说,在 C# 中是这样的:

Specifically, like this in C#:

#if (DEBUG)
   Debug Stuff
#endif

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

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天全站免登陆