如何将NAnt函数“path :: combine(path1,path2)”转换为MSBuild?

时间:2010-03-24 11:31:30

标签: msbuild nant

我需要转换函数“path :: combine(path1,path2)”。如果你有什么想法,请帮助我。谢谢!

2 个答案:

答案 0 :(得分:2)

使用CombinePath任务:

<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>

答案 1 :(得分:0)

为较新的MsBuild版本更新此帖子。从MSBuild 4.0及更高版本,您可以使用property functions

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