任务MSBuild如何遍历文件 [英] How does task MSBuild loop over files

查看:104
本文介绍了任务MSBuild如何遍历文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<Target Name="Build">
...

    <MSBuild
            Projects="$(MSBuildProjectFile)"
            Condition="'@(FilesToCompile)' != ''"
            Targets="buildcpp"
            Properties="CPPFILE=%(FilesToCompile.FullPath);OBJFILE=$(ObjectFolder)\%(FilesToCompile.Filename).doj;IncludeDirs=$(IncludeDirs)"
        />

FilesToCompile是所有.cpp文件的ItemGroup.

当我查看构建日志时,它显示了目标buildcpp正在为CPPFILE中的每个文件运行.

When I look at the build log, it shows the target buildcpp being run for each of the files in CPPFILE.

我理解这是我在逻辑上想要发生的事情,但是我的问题是元素

I understand that is what I logically want to happen but my question is, what rule of element <MSBuild> or the MSBuild schema causes task MSBuild to be executed for each value of CPPFILE?

简而言之,在文档中它指出将要发生的事情?

In short, where in the documentation does it state that is what will happen?

我想传递一次整个ItemGroup,而不是为每个项目一次调用MSBuild目标.

I want to pass in an entire ItemGroup once instead of calling the MSBuild target once for each item.

推荐答案

基于msbuild的概念称为批处理"-在您的情况下,是任务批处理(请参阅

The msbuild concept this is based on is called "batching" - in your case task batching (see MSBuild's task batching documentation).

任何包含对项目组的%()引用的任务都将被分成共享相同元数据的批处理,并且该任务将对每个批处理执行一次.使用诸如IdentityFullPath之类的内置元数据时,这实际上意味着为所有项目执行此任务",尽管也可能存在更复杂的用例.

Any task that contains a %() reference to an item group will be split up into batches that share the same metadata and the task will be executed once for each batch. When using built-in metadata like Identity or FullPath, this essentially means "execute this task for ever item", though there can also be more complex use cases.

这篇关于任务MSBuild如何遍历文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆