共用方式為


FindUnderPath 工作

更新:2007 年 11 月

判斷在指定的項目集合中,哪些項目的路徑在指定的資料夾之中或之下。

參數

下表說明 FindUnderPath 工作的參數。

參數

描述

Files

選擇性 ITaskItem[] 參數。

指定檔案,這些檔案的路徑會與 Path 參數所指定的路徑相比較。

InPath

選擇性的 ITaskItem[] 輸出參數。

包含在指定路徑下找到的項目。

OutOfPath

選擇性的 ITaskItem[] 輸出參數。

包含未在指定路徑下找到的項目。

Path

必要的 ITaskItem 參數。

指定用來做為參考的資料夾路徑。

範例

下列範例使用 FindUnderPath 工作來判斷 MyFiles 項目中包含的檔案路徑,是否可在 SearchPath 屬性指定的路徑下找到。在工作完成後,FilesNotFoundInPath 項目會含有 File1.txt 檔,而 FilesFoundInPath 項目則會含有 File2.txt 檔。

<Project xmlns="https://schemas.microsoft.com/developer/msbuild/2003">
    <ItemGroup>
        <MyFiles Include="C:\File1.txt" />
        <MyFiles Include="C:\Projects\MyProject\File2.txt" />
    </ItemGroup>

    <PropertyGroup>
        <SearchPath>C:\Projects\MyProject</SearchPath>
    </PropertyGroup>

    <Target Name="FindFiles">
        <FindUnderPath
            Files="@(MyFiles)"
            Path="$(SearchPath)">
            <Output
                TaskParameter="InPath"
                ItemName="FilesFoundInPath" />
            <Output
                TaskParameter="OutOfPath"
                ItemName="FilesNotFoundInPath" />
        </FindUnderPath>
    </Target>

</Project>

請參閱

概念

MSBuild 工作

其他資源

MSBuild 工作參考

MSBuild 概念