MSBuild ITaskItem RecursiveDir元数据消失 [英] MSBuild ITaskItem RecursiveDir metadata disappears
问题描述
我有一个自定义的MSBuild任务,该任务处理一组文件并返回其修改后的子集.基本上,我只是从输入中创建一个新的ITaskItem数组,跳过一些项目.
I have a custom MSBuild task, which processes a set of files and returns a modified subset of this. Basically, I just create a new ITaskItem array out of the input, skipping some items.
但是,当此结果集返回到MSBuild时,RecursiveDir元数据消失了!在自定义任务的Execute()方法末尾,它仍然具有正确的值,但是当我尝试在MSBuild中使用RecursiveDir时,我发现它为空!当然,这是一个很大的问题!
However, the RecursiveDir metadata disappears when this result set is returned to MSBuild! It is still with the correct values at the end of my custom task's Execute() method but when I then try to use RecursiveDir in MSBuild, I find that it is empty! This is, of course, quite a problem!
我该怎么办?这正常吗?其他元数据(如文件名和扩展名)仍然存在.身份也指向正确的文件.我不会在自定义任务中以任何方式修改元数据.
What should I do? Is this normal? The other metadata such as Filename and Extension is still there. Identity also points to the correct file. I don't modify the metadata in any way in my custom task.
我已经看到其他MSBuild任务库也返回ITaskItem数组,而没有进行任何特殊处理.但是没有人遇到这个问题吗?奇怪!
I have seen other MSBuild task libraries also return ITaskItem arrays without any special processing. Yet nobody has run into this issue? Bizarre!
我正在使用MSBuild 3.5.
I am using MSBuild 3.5.
推荐答案
是的,这很正常.您无能为力.我彻底地了解了MSBuild源代码,显然,进入自定义任务的项目和返回的项目是完全不同的事情. MSBuild首先创建自己的非常特殊的项目,后来它们变得明显笨拙".
Yes, this is normal. There is nothing you can do about it. I have gone through the MSBuild source code thorougly and apparently, the items going into a custom task and the items coming back out are completely different things. MSBuild creates its own very special items at first and later they become significantly "dumber".
我为此类情况找到的解决方案:
The solution I found for such cases:
- 创建一个包含所有内容的商品组.
- 创建一个自定义任务,该任务使用要删除的文件生成一个 ItemGroup .
- 使用< ItemGroup Remove ="@(ListFromCustomTask)"/>
这篇关于MSBuild ITaskItem RecursiveDir元数据消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!