Reference to $(ProgramFiles) incorrect

Jul 19, 2010 at 9:48 AM

Hello,

we have a project with a referennce to the programfiles environment variable.

<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="$(ProgramFiles)\MSBuild\Microsoft\StyleCop\v4.4\Microsoft.StyleCop.Targets" />
</Project>

Whe we build our solution the correct files are found in the following path

C:\Program Files (x86)\MSBuild\Microsoft\StyleCop\v4.4\Microsoft.StyleCop.Targets

But when i try to build the help files i receive the following error

SHFB: Error BE0065: BUILD FAILED: The imported project "C:\Program Files\MSBuild\Microsoft\StyleCop\v4.4\Microsoft.StyleCop.Targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.  D:\VsTs\Atlas\Production\OOL\StyleCop.targets

 When i change the referenct form $(ProgramFiles) to $(ProgramFiles (x86)) i receive an different error.

SHFB: Error BE0065: BUILD FAILED: The imported project "D:\MyProjectPath\)\MSBuild\Microsoft\StyleCop\v4.4\Microsoft.StyleCop.Targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.  D:\VsTs\Atlas\Production\OOL\StyleCop.targets

 

 

Coordinator
Jul 19, 2010 at 10:55 PM

It doesn't look like it's interpretting the parentheses in the environment variable name correctly.  You may need to escape them with a backslash, something like $(ProgramFiles \(x86\)).

Eric

 

Jul 27, 2010 at 7:46 AM

I tried that, but tha does not work either.

I downloaded the sources to find out where the problem occusr and the Project.Load causes the trouble.

I found out that for my purpose i can use de msbuld variable  $(MSBuildExtensionsPath) or $(MSBuildExtensionsPath32)

Greetz, René

Jul 29, 2010 at 3:13 PM
Edited Jul 29, 2010 at 5:09 PM
[ Deleted my comment, as the thing I described doesn't work in at least one case I just discovered :-( ]
Aug 6, 2010 at 11:14 PM

I had a similar issue and resolved it by setting a property and then using the property

  <PropertyGroup>
    <PlatformProgramFiles Condition="$(ProgramW6432) != ''">C:\Program Files (x86)</PlatformProgramFiles>
    <PlatformProgramFiles Condition="$(ProgramW6432) == ''">C:\Program Files</PlatformProgramFiles>
  </PropertyGroup>

<Import Project="$(PlatformProgramFiles)\etc\etc" />

It wasn't exactly the same as yours, but when I tried to use the env var directly, I got the same sort of problem with the parens in the (x86).

Maybe that will help...

David

Aug 9, 2010 at 6:30 AM

Thanks, this works