title: Build labelling in C# / Visual Studio 2010. Create a constant that can be used by pre-processor / compiler in AssemblyInfo.cs
body: <p>I have a large Visual Studio 2010 solution with some 25 projects. We have an automatic build process that kicks off a batch file, which, among other things, invokes msbuild on the .sln file.</p>
  
  <p>Our existing process (which also builds some Excel VBA and VB6 code) checks out a text file from our source control, increments a "build number" and re-submits it. We want a similar process to "build stamp" each C# project's AssemblyInfo.cs file.</p>
  
  <p>I could write a small utility that parses each AssemblyInfo and sets the AssemblyTitle field based on the build version text file we're using already. However, it seems that the compiler should be able to do this from a constant. Lots of sources on the web say that C# lacks a proper pre-processor, but that the compiler can do similar things using #define.</p>
  
  <p><strong>Question:</strong> Is there a way to define a compiler constant in Visual Studio that reads from a location provided in a text file / command line argument?</p>
  
  <p>Doing this would make our build-labelling routine more scalable when more projects are added, and mean fewer files being changed in source control.</p>