Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In MSBuild 4.0+, there's <a href="http://msdn.microsoft.com/en-us/library/ms164309.aspx" rel="noreferrer">a <code>$(MSBuildProgramFiles32)</code> property</a> for it, which you can confidently employ directly (especially if you're prepared to put a <code>ToolsVersion="4.0"</code> at the top of the file to guarantee it's going to be available and <a href="http://en.wikipedia.org/wiki/Fail-fast" rel="noreferrer">Fail Fast</a> if it's not).</p> <p>If you're not and need something that can Do The Right Thing even when executed in an MSBuild 2.0 or later environment (i.e., back to VS 2005 environments), the complete solution is:</p> <pre><code>&lt;PropertyGroup&gt; &lt;!--MSBuild 4.0 property--&gt; &lt;ProgramFiles32&gt;$(MSBuildProgramFiles32)&lt;/ProgramFiles32&gt; &lt;!--Use OS env var as a fallback:- 32 bit MSBuild 2.0/3.5 on x64 will use this--&gt; &lt;ProgramFiles32 Condition=" '' == '$(ProgramFiles32)'"&gt;$(ProgramFiles%28x86%29)&lt;/ProgramFiles32&gt; &lt;!-- Handle MSBuild 2.0/3.5 running in 64 bit mode - neither of the above env vars are available. http://stackoverflow.com/questions/336633 NB this trick (Adding a literal " (x86)" to the 64 bit Program Files path) may or may not work on all versions/locales of Windows --&gt; &lt;ProgramFiles32 Condition ="'$(ProgramFiles32)'=='' AND 'AMD64' == '$(PROCESSOR_ARCHITECTURE)'"&gt;$(ProgramFiles) (x86)&lt;/ProgramFiles32&gt; &lt;!--Catch-all - handles .NET 2.0/3.5 non-AMD64 and .NET 2.0 on x86 --&gt; &lt;ProgramFiles32 Condition=" '' == '$(ProgramFiles32)' "&gt;$(ProgramFiles)&lt;/ProgramFiles32&gt; &lt;/PropertyGroup&gt; </code></pre> <p>Unfortunately <a href="http://en.wikipedia.org/wiki/Progressive_enhancement" rel="noreferrer">Progressive enhancement</a> / <a href="http://remysharp.com/2010/10/08/what-is-a-polyfill/" rel="noreferrer">polyfill</a> overriding of the <a href="http://msdn.microsoft.com/en-us/library/ms164309.aspx" rel="noreferrer">MSBuild reserved property</a> name <code>MSBuildProgramFiles32</code> via either a <code>&lt;PropertyGroup&gt;</code> or <code>&lt;CreateProperty&gt;</code> is rejected by MSBuild 4.0+ so it can't be made tidier and still support .NET 2.0.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload