简体   繁体   English

Visual Studio 2008 - 解决方案的条件编译符号,而不是项目

[英]Visual Studio 2008 - Conditional Compilation Symbol for Solution, not Project

I want to use a compilation symbol, like DEBUG, except a different name, and have it associated with a solution, not a project, so that it applies to all the solution's projects. 我想使用一个编译符号,比如DEBUG,除了一个不同的名称,并将它与解决方案相关联,而不是项目,因此它适用于所有解决方案的项目。

Rather than define the same symbol in multiple projects, is there a way to define a symbol once, that applies solution-wide, via VS2008? 而不是在多个项目中定义相同的符号,有没有一种方法可以通过VS2008定义符号一次,适用于整个解决方案?

You can define own Build configurations with the Visual Studio Configuration Manager and define the symbol in the project build configuration. 您可以使用Visual Studio Configuration Manager定义自己的Build配置,并在项目构建配置中定义该符号。 It's easy and also works for C# (see my comment on Simon Wilson's answer). 这很简单,也适用于C#(参见我对Simon Wilson的回答的评论)。 To do so, just click on in the Solution Configuration Manager and check "Create new project configurations". 为此,只需在解决方案配置管理器中单击并选中“创建新项目配置”。 Then you can define the symbols in each project for the new build configuration. 然后,您可以在每个项目中为新构建配置定义符号。

One option you could use is to create a .cs file in 1 location with #define MYSYMBOL in it and add the file to each project in your solution using the Add as link option. 您可以使用的一个选项是在其中使用#define MYSYMBOL在1个位置创建.cs文件,并使用“添加为链接”选项将文件添加到解决方案中的每个项目。 This would allow you to have a single point of symbol/shared information definition. 这将允许您具有单点符号/共享信息定义。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM