开发者

How to convert NAnt function "path::combine(path1, path2)" to MSBuild?

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


Use the CombinePath Task:

<Project DefaultTargets="DefaultTarget" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <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>


Updating this post for newer MsBuild versions. From MSBuild 4.0 and up, you can use property functions

$([System.IO.Path]::Combine($(Path1),$(Path2)))
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜