从调试版本检测发布版本的最佳方法?.网
所以我有大约 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