MSBuild ITaskItem RecursiveDir 元数据消失

发布于 2024-08-18 16:04:52 字数 396 浏览 3 评论 0原文

我有一个自定义 MSBuild 任务,它处理一组文件并返回该文件的修改子集。基本上,我只是根据输入创建一个新的 ITaskItem 数组,跳过一些项目。

但是,当此结果集返回到 MSBuild 时,RecursiveDir 元数据消失!在我的自定义任务的 Execute() 方法末尾,它仍然具有正确的值,但是当我尝试在 MSBuild 中使用 RecursiveDir 时,我发现它是空的!这当然是一个很大的问题!

我应该怎么办?这是正常的吗?其他元数据(例如文件名和扩展名)仍然存在。身份还指向正确的文件。我不会在自定义任务中以任何方式修改元数据。

我看到其他 MSBuild 任务库也返回 ITaskItem 数组,而无需任何特殊处理。然而没有人遇到过这个问题吗?奇怪!

我正在使用 MSBuild 3.5。

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.

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.

I have seen other MSBuild task libraries also return ITaskItem arrays without any special processing. Yet nobody has run into this issue? Bizarre!

I am using MSBuild 3.5.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

巡山小妖精 2024-08-25 16:04:52

是的,这是正常的。你对此无能为力。我已经彻底浏览了 MSBuild 源代码,显然,进入自定义任务的项目和返回的项目是完全不同的东西。 MSBuild 首先创建自己的非常特殊的项目,后来它们变得明显“愚蠢”。

我针对这种情况找到的解决方案:

  1. 创建一个包含所有内容的 ItemGroup。
  2. 创建一个自定义任务,生成一个包含您要删除的文件的 ItemGroup。
  3. 使用

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:

  1. Create an all-inclusive ItemGroup.
  2. Create a custom task that generates an ItemGroup with the files you want to remove.
  3. Use <ItemGroup Remove="@(ListFromCustomTask)" />
断爱 2024-08-25 16:04:52

我刚刚遇到了同样的问题。通过将“RecursiveDir”元数据值显式设置为其当前值,我能够成功解决此“限制”(我认为是 MSBuild 错误)。

执行此操作后,我的输出 ITaskItem[] 保留了该值。

I just ran into this same exact issue. I was able to successfully work around this "limitation" (MSBuild bug in my opinion) by explicitly setting the "RecursiveDir" metadata value to its current value.

After doing this, my output ITaskItem[] retained the value.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文