Conflicts when editing multiple build process templates with TFS 2012

If you followed my small guide, or anyway if you have multiple build process templates in a single solution, you may have encountered this error when compiling with Visual Studio:

image_thumb1

“obj\Debug\TfsBuild_Process_BeforeInitializeComponentHelper.txt” was specified more than once in the “Resources” parameter. Duplicate items are not supported by the “Resources” parameter.

Diagnostic

This is actually easy to understand. When you add a Xaml workflow file into your solution, Visual Studio sets its properties to be part of the compilation:

image_thumb3

Visual Studio generates code and resources out of the Xaml language file, and each Xaml process template has its own class name and namespace (full name). The problem is that generally, TFS build process templates file have the same full class names. The consequence is that there are collisions. Generally, this class name is TfsBuild.Process (hence the name of the TfsBuild_Process_BeforeInitializeComponentHelper.txt resource), because we often duplicate existing build templates.

Solution

I’ve seen colleagues changing the Build Action setting it to None:

clip_image001_thumb

But you loose the controls issued by the compile process. There is something better do to, simply rename the class or namespace inside the Xaml file:

  • Open the file with the Xml Editor (right-clic => Open With… => XML (Text) Editor)
  • Look for the x:Class attribute on the first line

image_thumb4

  • Rename the namespace to something meaningful to you (ex:TfsBuild.Process => TfsBuildUpgrade.Process)
  • On the same line there is another mention of the namespace, rename it there two:

clip_image0014_thumb

Hopefully, it should now compile fine:

1>------ Rebuild All started: Project: BuildProcessEditing, Configuration: Debug Any CPU ------

1> BuildProcessEditing -> C:\Sources\MyBuildProcess\BuildProcessEditing\bin\Debug\BuildProcessEditing.dll

========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========

And the build should still work Winking smile  This way you can put all your build files in the same solution, this is more comfortable! I consider good practice to fix every new build process template I create. Hope this helps!

Leave a Reply

Your email address will not be published. Required fields are marked *