views:

33

answers:

1

Hi, I am converting some environment variables to property sheets for some C++ projects. This way when the projects are used from the branch or the trunk in SVN we don't have to use a junction to switch between the branch and trunk.

My property sheet, paths.vsprops, is in this format:

<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioPropertySheet 
ProjectType="Visual C++" 
Version="8.00" 
Name="Paths"
>
<UserMacro
    Name="EnvironmentVariable"
    Value=".\folder1\folder1;.\folder2\folder2"
    PerformEnvironmentSet="true"
/>
</VisualStudioPropertySheet>

Notice in the Value field that I'm using "." to try and get the current path to the vsprops file. Well this is not working and I'm getting some errors that files cannot be found. So, with all that explained, how should I go about getting the current path to the vsprops file in the XML code?

A: 

You can obtain the path to the current VCPROPS file by fetching the $(MSBuildThisFileDirectory):

<PropertyGroup>
    <MyProjectPath>$([System.IO.Path]::GetFullPath( "$(MSBuildThisFileDirectory)" ) )</MyProjectPath>
</PropertyGroup>

This MSFT blog has tons of info/tricks for doing things like this.
Have fun!

Bukes