反正是有#定义常量一个解决方案的基础? [英] Is There anyway to #define Constant on a Solution Basis?

查看:81
本文介绍了反正是有#定义常量一个解决方案的基础?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

反正是有的#define恒在Visual Studio解决方案基础?

Is There anyway to #define Constant on a Visual Studio Solution Basis?

可以定义一个常数的csproject的基础上,和一个可以把的#define恒 CS中的文件,但我不知道一个人是否可以将其定义在VS SLN基础?

One can define a constant on a csproject basis, and one can put #define constant in cs file, but I wonder whether one can define it on a vs sln basis?

推荐答案

您可以实际使用上Ritch的共同项目设置方法的变化。从本质上讲,你必须做出解决方案中的每个项目文件的最后一个变化:

You can actually use a variation on Ritch's approach with common project settings. Essentially you have to make a single change to the end of each project file in your solution:

  <PropertyGroup Condition="'$(SolutionDir)' == '' or
                     '$(SolutionDir)' == '*undefined*'">
      <SolutionDir>..\..\</SolutionDir>
    </PropertyGroup>
    <Import Project="$(SolutionDir)CommonSettings.targets" />
  </Project>

然后,你可以定义CommonSettings.targets遏制解决方案范围的设置。

Then you can define CommonSettings.targets to contain the solution wide settings.

  <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"
           ToolsVersion="3.5">
      <PropertyGroup>
          <TacoBuild>true</TacoBuild>
      </PropertyGroup>
  </Project>

除非你想忽略或合并在每个项目中已定义的项目设置,这基本上它。下面的链接讨论了如何在一些细节上做到这一点。

That's basically it unless you want to override or merge project settings already defined in each project. The link below discusses how to do this in some detail.

<一个href=\"http://www.ademiller.com/blogs/tech/2007/12/common-project-settings-for-your-visual-studio-solution/\">http://www.ademiller.com/blogs/tech/2007/12/common-project-settings-for-your-visual-studio-solution/

这篇关于反正是有#定义常量一个解决方案的基础?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆