This project has moved and is read-only. For the latest updates, please go here.

Using environment variables

Topics: User Forum
Dec 3, 2010 at 3:11 PM

Hi !

I use SHFB on both Windows XP and Windows 7 64 bits

I need to reference libraries from Silverlight with a path depending on the system

  • C:\Program Files\Reference Assemblies\Microsoft\Framework\Silverlight\v4.0\System.Windows.Controls.dll on Windows XP
  • C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\Silverlight\v4.0\System.Windows.Controls.dll on Windows 7 64 bits

Using Visual studio Command Line, the only shared and valid variable on both Windows XP and Windows 7 64 bits is %WindowsSdkDir% pointing to C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A.
I can use relative path $(WindowsSdkDir)\..\..\..\Reference Assemblies\Microsoft\Framework\Silverlight\v3.0\System.Windows.Controls.dll.

Q1 : Are Visual Studio Command Line environment variables available ?

Q2 : How can I get all the environment variables available when building ?

Q3 : Should I use my own environment variable ?

Q4 : What would be the best way ?


Philippe L.

Dec 7, 2010 at 8:36 PM

You can specify environment variables within the path properties using MSBuild syntax.  For example: $(ProgramFiles).  Note that some may vary based on whether you are on a 32-bit or 64-bit OS.  If you want to define your own, you can pass in the definition as a command line option (/p:MyVar=SomeValue).  If building from within the GUI, you may need to add the custom variables to the UserDefinedProperties project property with a condition and a default value so that they exist when building from within the GUI.  See the help topic on it for more information.




Dec 9, 2010 at 8:53 AM
Edited Dec 9, 2010 at 8:56 AM

I am building both using TFS daily build and and the SHFB GUI.

I try to use my custom property

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

But it seems that this custom property is not replaced in the HintPath of Reference

<Reference Include="system">
   <HintPath>$(ProgramFilesX86)\Reference Assemblies\Microsoft\Framework\Silverlight\v4.0\system.dll</HintPath>

I finally use Choose and it works

When Condition="'$(ProgramW6432)' != ''"> <ItemGroup> <Reference Include="system"> <HintPath>C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\Silverlight\v4.0\system.dll</HintPath> </Reference> <Reference Include="System.Core"> <HintPath>C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\Silverlight\v4.0\System.Core.dll</HintPath> </Reference> ... </ItemGroup> </When> <When Condition="'$(ProgramW6432)' == ''"> <ItemGroup> <Reference Include="system"> <HintPath>C:\Program Files\Reference Assemblies\Microsoft\Framework\Silverlight\v4.0\system.dll</HintPath> </Reference> <Reference Include="System.Core"> <HintPath>C:\Program Files\Reference Assemblies\Microsoft\Framework\Silverlight\v4.0\System.Core.dll</HintPath> </Reference> ... </ItemGroup> </When> </Choose>