检测从调试版本发布版本的最好方法? 。净版本、方法

2023-09-02 01:33:53 作者:醉诗仙南山鹤

所以,我有我与MVC应用程序使用约10个短css文件。 还有像 error.css login.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文件,尽量减少他们和所有的好东西。我只需要知道,如果有一种方法来去除,如果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#有以下preprocessor指令:

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