views:

120

answers:

1

Can't figure out how to get the last part of

$(MSBuildProjectDirectory)

For example, if the value was "c:\development\projects\project_branch" then, I want just the last part "project_branch".

Any ideas?

Thanks,

Sean

+1  A: 
<Project DefaultTargets="BuildAll" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"&gt;

    <Target Name="GetMSBuildProjectLocalDirectory">
        <CreateItem Include="$(MSBuildProjectDirectory)">
            <Output ItemName="MSBuildProjectDirectoryMeta" TaskParameter="Include"/>
        </CreateItem>
        <CreateProperty Value="%(MSBuildProjectDirectoryMeta.Filename)">
            <Output PropertyName="LocalDirectory" TaskParameter="Value"/>
        </CreateProperty>
    </Target>

    <Target Name="BuildAll" DependsOnTargets="GetMSBuildProjectLocalDirectory">
        <Message Text="$(LocalDirectory)" />
    </Target>

</Project>
mhanney