I have a C# project file (.csproj) containing references to $(ProgramFiles). I am using 64bit Windows 7. When I compile this project file within Visual Studio 2010, it locates the file correctly in c:\Program Files (X86).
If I try to be clever and instead use Microsoft.Build.Evaluation.ProjectCollection.LoadProject([project file]), in an attempt to build it in code, it evaluates $(ProgramFiles) incorrectly as c:\Program Files.
Any idea what the cause of the problem could be?
Visual Studio 2010 is a 32-bit process, and WOW will give
c:\Program Files (X86)for 32-bit processes.My assumption here:
Is that when you are doing it “in code”, your code is executing a x64, so you get the normal environment value.
You can use the
ProgramFiles(x86)environment variable from x64 if you need the path to the x86 program files directory. In MSBuild, that’s$(MSBuildProgramFiles32).