Error with XAML

Feb 22, 2013 at 7:13 PM
I have successfully added the TfsVersioning 2.0 template to TFS2012. Builds work fine, but when I try to edit the workflow and add new activities, I get the error "Activity could not be loaded because of errors in the XAML."

Thanks in advance for any help on this problem.

Pat
Feb 22, 2013 at 7:14 PM
As additional info... this error occurs as soon as I open VersioningBuildTemplate20.xaml.
Mar 14, 2013 at 8:14 AM
Got the same error with xaml.

Previously used the 1.5 version, everything worked.

Updated to the 2.0, and build for NuGetterMultiPkgBuildVersionedTemplate20.xaml fails with this error:
TF215097: An error occurred while initializing a build for build definition \SharedCode\ServiceLibWithNUGetterVerioning: Cannot create unknown type '{clr-namespace:TfsBuild.Versioning.Activities;assembly=TfsBuild.Versioning.Activities}VersionAssemblyInfoFiles'.

And build error for the NuGetterMultiPkgBuildTemplate20.xaml file:
TF215097: An error occurred while initializing a build for build definition \SharedCode\ServiceLibWithNUGetter: The invocation of the constructor on type 'TfsBuild.NuGetter.Activities.NuGetterProcess' that matches the specified binding constraints threw an exception.
Apr 17, 2013 at 3:42 PM
Is there any solution to this problem?

I have tried adding the custom assembly to the toolbox before loading the VersioningBuildTemplate20.xaml but it still doesn't work.
Apr 17, 2013 at 5:58 PM

Try adding the custom assembly to the GAC

Apr 18, 2013 at 7:48 AM
PatSpeer wrote:
Try adding the custom assembly to the GAC
Thanks, this worked.
Just make sure you reopen visual studio after GAC installation.

There is also complete documentation in the "TfsVersioning User and Development Guide.pdf" that comes with the download package.
This step was also described there so shame on me...


Thanks PatSpeer.
Jun 13, 2013 at 1:02 AM
Here's another way to resolve this. The issue with the GAC is that is does not match the context in which the build machine will likely use it. Granted, one can also place Code Activities in the GAC on every build machine, but that's not a practice in which I would engage. Personally, if I can avoid the GAC, I will at all costs.

Rather, to view the xaml:
  1. Close the xaml file in VS.
  2. Create a new solution/project in Visual Studio.
  3. Manually add references to all the TeamFoundation assemblies to your new project. (Be sure to use the v11 if TFS2012 or v10 if TFS2012.)
  4. Right click on your project and "Add Existing..." BUT when the dialog box comes up to select it, notice that the "Add" button has a drop down with "Add as link". Add it to your project as a link.
  5. Add all custom assemblies into the $/Project/BuildProcessAssemblies/CustomAssemblies folder in source control
  6. Be sure to set up your build controller to pull assemblies from that location.
  7. Open the xaml file link in VS. In your toolbox, add the missing assemblies if they are not already there.
  8. Save your new solution. You can use it in the future to edit all of your xaml files.
Now that said, I've had several occassions with other build process templates or activity libraries in which the v11 assemblies have been used (when viewed in the actual xaml file in a text editor) for a TFS 2010 process template or, likewise, v10 assemblies in a TFS 2012 build process template. These can often be fixed by replacing (using a text editor) the version of the assembly in the namespace reference. The hardest part is actually finding the exact reference string.

For what it is worth, this is the same process that I use to create custom code activities.

I credit Hashimi and Bartholomew, authors of Inside the Microsoft Build Engine: Using MSBuild and Team Foundation Build. Chapter 16 contains some related instructions.