Is there anyway to #define CONSTANT on a solution basis?

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>

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.

http://www.ademiller.com/blogs/tech/2007/12/common-project-settings-for-your-visual-studio-solution/

Leave a Comment