tags:

views:

146

answers:

1

I need to convert the function "path::combine(path1, path2)". Please help me if you have some idea. Thank you!

+1  A: 

Use the CombinePath Task:

<Project DefaultTargets="DefaultTarget" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"&gt;
    <PropertyGroup>
        <MyBasePath>.\a\b</MyBasePath>
        <MySecondPath>c\d</MySecondPath>
    </PropertyGroup>

    <Target Name="Combine">
        <PropertyGroup>
            <MySecondPath Condition="$(MySecondPath)==''">.\</MySecondPath>
        </PropertyGroup>
        <CombinePath BasePath="$(MyBasePath)" Paths="$(MySecondPath)">
            <Output TaskParameter="CombinedPaths" PropertyName="CombineOutput" />
        </CombinePath>
    </Target>

    <Target Name="DefaultTarget" DependsOnTargets="Combine">
        <Message Text="Result from Combine is $(CombineOutput)" />
    </Target>

</Project>
Filburt
Thank you! It's so strange because I look for the task in MSBuild Task Reference from http://msdn.microsoft.com/en-us/library/7z253716(v=VS.90).aspx. Microsoft doesn't list <CombinePath... > there. :(
Nam Gi VU
I've tested I found that: When the second path is empty, CombinePath doesn't return the first path. So, we should note this small difference when compared with NAnt path::combine.
Nam Gi VU