本文介绍了如何在c#中定义预处理器指令Global。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
-SA —SA This works for me in webconfig:
<system.codedom>
<compilers>
<compiler>
language="c#;cs;csharp" extension=".cs"
compilerOptions="/d:custompreprocessor"
type="Microsoft.CSharp.CSharpCodeProvider,
System, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089" />
</compiler></compilers></system.codedom>
Hi.My问题是如何在网站上的所有C#类的一个地方定义预处理器指令全局。
解决方案它被定义为命令行参数编译器。从C#编译器CSC.EXE文档中可以看到,您可以使用命令行参数 / define : msdn.microsoft/en-us/library/vstudio/0feaad6z.aspx [ ^ ], msdn.microsoft/en-us/library/vstudio/78f4aasd .aspx [ ^ ]。 在MSBuild项目中,这是根据配置和平台属性在属性组中定义的 < DefineConstants > TRACE; DEBUG; SomeCustomConditionalCompilationSymbol < / DefineConstants >
此功能的GUI前端界面取决于特定的IDE。在Visual Studio中,这是在项目属性页面,构建选项卡,条件编译S y mbols字段中完成的。
这在webconfig中适用于我: < system.codedom > < 编译器 > < 编译器 > language =c#; cs; csharpextension =。cs compilerOptions =/ d:custompreprocessor type =Microsoft.CSharp.CSharpCodeProvider, System,Version = 2.0 .0.0,Culture = neutral, PublicKeyToken = b77a5c561934e089/> < / compiler > < / compilers > < / system.codedom >
Hi.My Question is how to define Preprocessor Directive Global at one place for all C# classes in website.
解决方案 It is defined as a command-line argument of a compiler. As you can see from the C# compiler CSC.EXE documentation, you can use the command-line argument /define: msdn.microsoft/en-us/library/vstudio/0feaad6z.aspx[^], msdn.microsoft/en-us/library/vstudio/78f4aasd.aspx[^]. In the MSBuild projects, this is defined in a property group, per Configuration and Platform properties, in <DefineConstants>TRACE;DEBUG;SomeCustomConditionalCompilationSymbol</DefineConstants>The GUI front-end interface to this feature depends on particular IDE. In Visual Studio, this is done on the project Properties page, the tab "Build", int the field "Conditional Compilation Symbols".
更多推荐
如何在c#中定义预处理器指令Global。
发布评论