March 2010 - Posts

TFS42097: A work item could not be created due to a field error.

Why oh why? 

The most common reason for this particular error message is you have a customized Bug Work Item Type which fields do not match what is expected in the TFSBuild.proj file.

Local or Global Fix? 

There are several ways you can solve this problem which can be applied to individual build definition TFSBuild.proj or as a TFSBuild.proj template change to prevent the error from happening again when you create a new build definition. 

To change the template, make your changes to the following file: C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\1033\TFSBuild.projNOTE: You need to make the changes on the Build Manager (whoever is responsible to create the build definition) machine and not on the TFS server.  As I said above, do this only when you want subsequent (any new) Build Definition to be fixed automatically.

To change each individual build, navigate to the [Insert your Team Project name]\TeamBuildTypes\[Insert build definition name here] in your Source Control Explorer and change the TFSBuild.proj file for that particular build.  This should let you pick and choose where to apply the fix.

Options

  1. If you don't care about creating the work item at all as part of your build failure, just add <SkipWorkItemCreation>true</SkipWorkItemCreation> inside the <PropertyGroup> node.  This will prevent the Bug Work Item creation when the build failed.
  2. If you want TFS Build to create the task in your custom "Bug" Work Item, make sure to map or change the field definition in the <WorkItemFieldValues>...</WorkItemFieldValues> node in the TFSBuild.proj file.
  3. If you want TFS Build to use a different Work Item template (and not your custom "Bug" Work Item), you can create a specialized Buld Failure Work Item by importing the standard Bug Work Item from an out of the box TFS process template such as the MSF Agile one and change the the <WorkItemType>Bug</WorkItemType> node in the TFSBuild.proj file to <WorkItemType>Bug Failure</WorkItemType> (Replace Bug Failure with whatever you name your imported Bug work item as).

Additional References

Recommendation

  • Install TFS Power Tools on your development environment.  It comes with Process Template Editor VS add-in for doing visual Work Item customization instead of the regular XML edit method using witimport / witexport command line tools.
Share this post: | | | |
Posted by Jimmy Chandra | with no comments