Search code examples
c#msbuildcode-generationcompilationitaskitem

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[]. 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.


Solution

  • It turns out there is a TaskItem class already. 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. No problem