title: Setting environment variables in pre-build event and using in compilation step
body: <p>In Visual Studio 2003, I am trying to set an environment variable in the pre-build event that will then be used in the compilation step, but the value doesn't seem to be propagated.  For example, if the pre-build event contains this (either directly or within a batch file):</p>
  
  <pre><code>set MY_LIB_VERSION=1.0.0
  </code></pre>
  
  <p>and AdditionalIncludeDirectories has this:</p>
  
  <pre><code>c:\path\to\library\my_lib_v$(MY_LIB_VERSION)\include
  </code></pre>
  
  <p>then I would expect the compilation to work if the <code>my_lib_v1.0.0</code> directory exists.  But instead, I get</p>
  
  <pre>
  c:\path\to\prog\my_prog.c(22) : fatal error C1083: Cannot open include file: 'my_lib.h'
  Project : warning PRJ0018 : The following environment variables were not found:
  $(MY_LIB_VERSION)
  </pre>
  
  <p>I deduce that the environment variable set in the pre-build event therefore isn't being propagated to the compilation step, but I may be missing something.</p>
  
  <p><strong>How can I set the environment variable in the pre-build event and use it in the compilation step?</strong></p>
  
  <p>(Alternatively, any other sensible ways of defining a library version once and using it several times for AdditionalIncludeDirectories and AdditionalLibraryDirectories would do just as well.)</p>
  
  <hr>
  
  <p><strong>Update</strong>: I ended up solving our problem in a different way.  We are using Subversion, and set up the <code>svn:externals</code> property on a subdirectory of the project source called <code>dependencies</code>, such that a checkout of the project would additionally check out <code>&lt;svn_path&gt;\libraries\my_lib_v1.0.0</code> and call it <code>dependencies\my_lib</code> in the working copy.  Then the project settings could refer to <code>dependencies\my_lib\include</code> and suchlike.  Upgrading to version 1.0.1 of <code>my_lib</code> is then simply a matter of editing the <code>svn:externals</code> property -- the code and project settings did not need to change.</p>