Thursday, February 09, 2006

Minor bug in MSBuild on x64 Machine

The reserved property MSBuildExtensionsPath apparently always returns "C:\Program Files\MSBuild" in the command line no matter where it is actually installed. Oops. On my x64 machine, this path is totally invalid, as all standard programs - including vs05 and related apps - are installed to "C:\Program Files(x86)\". Only 64-bit programs go into the standard "Program Files" path.

This does not appear to be true when compiling my modified project file in VS05. Not sure what to make of this discrepancy.
Submit this story to DotNetKicks

1 comment:

Anthony said...

Yeah, I ran into this a couple of hours ago with VS2008 B2. Supposedly, it's by design according to the MSBuild team. Still sounds like a bug to me.

Anyway, my workaround was:
<PropertyGroup>
<WebAppTargetsSuffix>Microsoft\VisualStudio\v9.0\WebApplications\Microsoft.WebApplication.targets</WebAppTargetsSuffix>
<MSBuildExtensionsPathx86>$(ProgramFiles(x86))\MSBuild</MSBuildExtensionsPathx86>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\$(WebAppTargetsSuffix)" Condition="Exists('$(MSBuildExtensionsPath)\$(WebAppTargetsSuffix)')" />
<Import Project="$(MSBuildExtensionsPathx86)\$(WebAppTargetsSuffix)" Condition="Exists('$(MSBuildExtensionsPathx86)\$(WebAppTargetsSuffix)')" />

There's probably a better way to let MSBuild find the correct one, but this makes the intention pretty clear.