This documentation is archived and is not being maintained.

CreateNewWorkItem Task

By default, Team Foundation Build creates a work item if it detects a compilation error or static analysis failure. The CreateNewWorkItem task creates a work item of the specified type and with the specified title and description. The Microsoft.VSTS.Build.FoundIn field is set to the value of BuildId property, and any custom field values specified in the WorkItemFieldValues property are set as specified.




Specifies the Team Foundation Server URL. For example, http://MyServer:8080.


Specifies the Team Foundation Build build number.


Specifies the build URI.


Specifies the work item description. The default value of this property is specified in the TFSBuild.proj file of the build definition as follows:

<!-- Description for the work item created on build failure -->
    <DescriptionText>This work item was created by Team Build on a build failure.</DescriptionText>


Specifies the team project name.


Specifies the work item title.


Specifies a list of field names and values for the created work item.

Specify these values as a semicolon-separated list of name, value pairs. For example, if you want to set priority=1, severity=2, and rank=0, define the MSBuild property as follows in the XML shown here:

   priority =1; severity=2; rank =0


Specifies the work item type. For example, "bug."

You must use a valid work item type. If this property is not defined, the default work item type is bug.

The CreateNewWorkItem task is defined in the Microsoft.TeamFoundation.Build.Tasks.VersionControl.dll. The Microsoft.TeamFoundation.Build.targets file contains an instance of the CreateNewWorkItem task that Team Foundation Build uses as a default implementation for the CreateWorkItem target. You can also customize the build process by defining a different instance of the CreateNewWorkItem task for a build definition in the TfsBuild.proj file.

The <root>:\Program Files\MSBuild\Microsoft\VisualStudio\v9.0\TeamBuild folder on the Team Foundation Build computer contains the Microsoft.TeamFoundation.Build.targets file.

Valid Work Item Types

Each team project is created with a particular methodology. In Team Foundation, the MSF for Agile Software Development methodology defines Bug, Quality of Service, Risk, Scenario, and Task work item types. The CMMI for Process Improvement methodology defines Bug, Change Request, Issue, Requirement, Review, Risk, Scenario, and Task work item types. You can also define your own work item type by customizing an existing work item type definition. For more information, see Customizing Project Tracking Data, Forms, Workflow, and Other Objects.

You must define a valid work item type for the CreateNewWorkItem task for build integration and you must define a FoundIn field. For more information, see Adding Integration Fields in Work Item Types.

Default Behavior

If you leave the WorkItemType property undefined, the CreateNewWorkItem task uses the Bug work item type.

Notes on WorkItemFieldValues Property

You use the WorkItemFieldValues to specify the field values of the work item as a semicolon-separated list of name, value pairs. If you specify a field name that does not exist, the corresponding <name, value> pair is ignored. For example, if you want to set the severity field to 1, but severity is not defined in the work item type, the input is ignored.

If the work item that you define has required fields without default values, you must provide values in the WorkItemFieldValues property. For example, the Defect work item type has a required field that is named Priority. The values of Priority are 0, 1, 2, or 3, and no default setting is specified. The task fails if you specify an invalid value for a required field. For example, if you set the Priority to 5, the CreateNewWorkItem task fails.

You cannot specify the CreatedBy and State fields of the work item. The CreatedBy field is read-only. It is set by the work item tracking object model (OM). The State field cannot be specified because the work item tracking OM cannot have multiple start states.

The following example sets the WorkItemFieldValues in the TfsBuild.proj file for the work item created on build failure.

<WorkItemFieldValues>Area Path=$(AreaPath);Iteration Path=$(IterationPath);Severity=1;Priority=0;Symptom=build break;Steps To Reproduce=Start the build using Team Build;Source=Development;How Found=Build Break;Assigned To=Jim Wilson</WorkItemFieldValues>

The following example uses the CreateNewWorkItem task in the TfsBuild.proj file, to create a custom work item on build failure.

<!-- Add the UsingTask to the top of the TFsBuild.proj file after the schema definition-->
<UsingTask TaskName="Microsoft.TeamFounadtion.Build.Tasks.CreateNewWorkItem"
   AssemblyFile="$(TeamBuildRefPath)\Microsoft.TeamFoundation.Build.Tasks.VersionControl.dll" />
<!-- Add the following XML after the closing </ItemGroup>-->
<!-- and before the closing </Project>-->
         Description="The CreateNewWorkItem task created this bug."
         Title="Bug in $(BuildNumber)"
         WorkItemType="$(WorkItemType)" />

The following example shows the default instance of the CreateNewWorkItem task as defined in the Microsoft.TeamFoundation.Build.targets file.

    ContinueOnError="true" />