Home > Back-end >  Is the TaskFactory attribute really optional in the <UsingTask> element?
Is the TaskFactory attribute really optional in the <UsingTask> element?

Time:12-11

Is the TaskFactory attribute really optional in the <UsingTask> element ?

Microsoft's Documentation states that it is optional.

I played with the syntax of the <UsingTask> element but I could not come up with a case in which the TaskFactory attribute did not have to specified.

Below is the smallest snippet of code that will compile for me without errors:

<UsingTask TaskName="TestMe" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll" >
  <Task>
    <Code/>
  </Task>
</UsingTask>

My interest is academic.

CodePudding user response:

Yes. The TaskFactory is optional.

If you compile the TestMe task into an assembly named TestMe.dll, you can use UsingTask as follows:

  <UsingTask TaskName="TestMe" AssemblyFile="TestMe.dll" />

See "Example 2" in Microsoft's Documentation.

  • Related