简体   繁体   English

在MSBuild任务中生成代码

[英]Generating Code in an MSBuild task

I am creating an MSBuild task that will generate one or more files, I have a Task with an [output] property that is of type ITaskItem[]. 我正在创建一个将生成一个或多个文件的MSBuild任务,我有一个带有[output]属性的任务,其类型为ITaskItem []。 My question is, do I need to implement that interface myself or is there a class I can use already? 我的问题是,我是否需要自己实现该界面,或者我是否可以使用该类?

I want them to be Compile task items that get added to the list of files to compile. 我希望它们是编译被添加到要编译的文件列表的任务项。

It turns out there is a TaskItem class already. 事实证明,已经有一个TaskItem类。 It's pretty general but should work just fine. 这很普遍,但应该工作得很好。 If you set the ItemName="Compile" on the output element in your targets file it will create them as Compile items and add them to the collection. 如果在目标文件的输出元素上设置ItemName =“Compile”,它将创建它们作为编译项目并将它们添加到集合中。 No problem 没问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM