Customize Team Build 2010 – Part 7: How is the custom assembly found?

by Ewald Hofman 27. May 2010 04:36

In the series the following parts have been published

  1. Part 1: Introduction
  2. Part 2: Add arguments and variables
  3. Part 3: Use more complex arguments
  4. Part 4: Create your own activity
  5. Part 5: Increase AssemblyVersion
  6. Part 6: Use custom type for an argument
  7. Part 7: How is the custom assembly found
  8. Part 8: Send information to the build log
  9. Part 9: Impersonate activities (run under other credentials)
  10. Part 10: Include Version Number in the Build Number
  11. Part 11: Speed up opening my build process template
  12. Part 12: How to debug my custom activities
  13. Part 13: Get control over the Build Output
  14. Part 14: Execute a PowerShell script
  15. Part 15: Fail a build based on the exit code of a console application
  16. Part 16: Specify the relative reference path

The solution that is created in the parts 4 till 6 uses an assembly that contains the custom activities, the custom types and the custom editors. When another person edits a build definition based on the modified Build Process Template, that person was able to use the custom types and editors. I wondered how Visual Studio was able to find the correct assembly.

I figured out that it looks in the following locations

  1. The “version control path to custom assemblies” that is specified in the build controller the build uses
  2. The GAC
  3. The Visual Studio probing path

If the assembly can still not be found, try to reopen Visual Studio. This will ensure that the assembly is reloaded.

Version control path to custom assemblies

When you edit the build definition, you specify the controller you want to use.

image

In this build controller, you can set the Version Control path that contains the assemblies that are used by the Build Process Template. You can see the information of the build controller by right clicking on the Builds node in the Team Explorer window. Select then Manage Build Controllers.

image

A dialog pops up with all the build controllers and its agents

image

Select the controller you use in the build definition, and click on Properties

image

Over here you can specify the path where the assemblies live in Source Control you want to use when someone Edits a build definition.

The Visual Studio probing path (or GAC)

 

 

 

 

If you don’t want to specify the assembly via the Version Control path in the build controller, you can also make it available by installing it in the GAC or in one of the Visual Studio probing path.

You can find the probing paths of Visual Studio by editing the devenv.exe.config file. You can find this file at C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE (or C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE for 32 bits machines)

image

By default this config contains the following directories (relative to the C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE directory):

  • PublicAssemblies
  • PrivateAssemblies
  • CommonExtensions\Microsoft\TemplateProviders
  • PrivateAssemblies\DataCollectors
  • PrivateAssemblies\DataCollectors\x86
  • CommonExtensions\Microsoft\Editor
  • CommonExtensions\Platform\Debugger

UPDATE 31-8-2010: Thanks to venkateswar who provided the following solution for a common problem in http://social.msdn.microsoft.com/Forums/en-US/tfsbuild/thread/2b24609d-fc8f-4908-bdc5-6986d5e53ecc/

"TF21509:An error occured while initializing a build definition \CustomBuildTasks\BuildName:Cannot create
unknown type '{clr-namepace:NamespaceName,asembly=AssemblyName}Activityname'."

You can solve this by adding the attribute [BuildActivity(HostEnvironmentOption.All)] at class level.

[BuildActivity(HostEnvironmentOption.All)]
public sealed class CustomActivity : CodeActivity

See more info on this at http://www.ewaldhofman.nl/post/2010/04/29/Customize-Team-Build-2010-e28093-Part-4-Create-your-own-activity.aspx (step 10)


UPDATE 30-9-2010: Thanks to Sven Hubert who was so kind to share his solution.

If your custom assembly uses a dependent assembly (reference) which is needed to run activities, they will not get deployed properly. If this is the case you will get “unknown type” errors on build definition initialization.

To work around this issue, add a fake CodeActivity to your dependent assembly with the following class scoped attribute:

[Microsoft.TeamFoundation.Build.Client.BuildActivity(Microsoft.TeamFoundation.Build.Client.HostEnvironmentOption.All)]
Public sealed class FakeActivity : CodeActivity


 

You can download the full solution at BuildProcess.zip. It will include the sources of every part and will continue to evolve.

Tags:

Team Build | VSTS 2010

Comments

6/11/2010 5:34:06 AM #

Padda

Hi,

Did you point the Build > Process > Process Template (Build process file) to the CustomTemplate.xaml within the solution, or did you move the CustomTemplate.xaml to the BuildProcessTemplates folder and then pointed the Build to this new location?

The reason I ask is, when I move the CustomTemplate.xaml to the BuildProcessTemplates folder, and then open the CustomTemplate.xaml in Visual Studio from the new location, I get errors where it can't resolve the references to the CustomAssemblies, i.e. my custom activities. Note: the build run fine, and completes successfully. This makes sense to me, in that the build controller is told where to look for Custom Assemblies, but Visual Studio itself does not.

Am I missing something, or is this the expected behavious by design and should I be opening the CustomTemplate.xaml from within the solution?

Many thanks
Padda

Padda United Kingdom |

6/12/2010 11:57:11 PM #

Ewald Hofman

I open the xaml from within the solution. I also point the Build Process file to the xaml at the solution location.

Ewald Hofman Netherlands |

10/19/2010 2:47:20 PM #

Kamal

Hi,

I have a custom assembly that uses a dependent assembly. The custom type is defined in dependent assembly and the editor is in custom assembly. I have also specified this editor for a parameter in xaml. When I try to open the build definition to modify this custom argument, i dont find a button that opens the editor. Have you come across such behavior?

Thanks,
Kamal

Kamal United States |

10/20/2010 2:38:17 PM #

Ewald Hofman

When you say that you have specified the editor, do you mean that you added the parameter to the metadata argument?

Ewald Hofman Netherlands |

11/3/2010 4:12:07 PM #

David Keaveny

I've got a two-project solution similar to your sample BuildProcess solution, Ewald - one assembly contains the code activity, the custom type and the custom type editor, and the other assembly contains a workflow that references the first assembly. When I open the workflow designer, I can see my code activity from the references assembly, but not the custom type.

Where's a good point to begin when figuring out what's gone wrong?

David Keaveny Australia |

11/3/2010 8:41:55 PM #

Ewald Hofman

You can open up a second Visual Studio, start the Attach to process command to debug devenv (the instance of visual studio where the workflow is in).
Then hit the Pause and open up the Modules window.

You will now see in this window which dll the workflow uses.

Ewald Hofman Netherlands |

11/9/2010 5:32:32 AM #

trackback

Part 14: Execute a PowerShell script

Part 14: Execute a PowerShell script

Ewald Hofman |

11/10/2010 9:14:25 AM #

pingback

Pingback from blogs.like10.com

TechDays 2010 Presentations « Microsoft Team Foundation Server, SharePoint Server, .NET, and SQL Server

blogs.like10.com |

1/12/2011 9:01:01 AM #

Gary Miner

Ewald, Thank you very much for this walk through it has been very helpful. The conundrum I am find myself in is how to manage multiple XAML files for multiple Team Projects which use custom activities, in a team with several people. We started off with a XAML file that we added custom activities within the solution as you describe in step 4. Then we moved that XAML file to the Target Team project and configured the build controller. This works fine.

However, if I open the XAML file in the new location I get error as Padda pointed out above. So, I setup our orginal solution to strongly name the dlls and then put them in the gac. I am now able to open the XAML file without errors but I don't see any of the custom activities in the tool bar. So this is not going to fly either.

So we reverted back to what you mentioned "I open the xaml from within the solution. I also point the Build Process file to the xaml at the solution location."
Which is fine, but we have multiple team projects that need to use the custom activities. So what we end up with is teamprojectA.xaml and teamprojectb.xaml in the project folder, but we can only have one xaml file included in the project at a time. Ugh.. what a mess.

I have dozens of projects that I will need to setup, this just seems like a unfortunate way to have to manage this.

Am I missing something or is this what I am left with?

Gary Miner United States |

1/12/2011 2:02:12 PM #

Ewald Hofman

Why can't you add multiple xaml files to a project?

You might want to add your findings to https://connect.microsoft.com/visualstudio

Ewald Hofman Netherlands |

5/26/2011 9:14:13 AM #

Chad Shaffer

Hi Gary,

You may have already gotten past this issue already, but Ewald is right, there is no reason you can't have multiple xaml files in the project.  Just make sure that when you add them, you change the file's Build Action to None, otherwise you'll get a slew of errors when you compile.  This may be obvious to some people, but it tripped me up a bit at first.  Hope you got it figured out!

Chad Shaffer United States |

1/16/2011 3:46:46 PM #

Ted

If you have an assembly with custom types only (no activities), instead of adding a fake activity to force the dll to be loaded like you have suggested, you can simply add the [BuildExtension(HostEnvironmentOption.All)] attribute to one or more of the custom classes. This will then allow it to be loaded from the "version control path to custom assemblies" path, rather than needing to GAC the assembly.

Ted Canada |

1/17/2011 5:16:51 AM #

Ewald Hofman

Ted,

Thanks for this great addition.

Ewald Hofman Netherlands |

1/20/2011 9:47:25 AM #

pingback

Pingback from danielcolomb.com

Dependency Replication in TFS 2010 « danielcolomb.com

danielcolomb.com |

2/3/2011 9:29:13 AM #

Srikanth Srinivasan

I have created some custom activities and tested them. They work fine and are checked in. But when I checkout the XAML file on another machine the activities are not able to locate the dlls since they are referenced by the build controller only when a build is queued, that makes sense. This causes a problem if I want to edit the XAML file as I can no longer access the custom activities (they appear in red as errors). As per your tutorial it is possible to add the XAML file to a project file, reference the needed dlls and add them to the same solution. That makes viewing the XAML file possible.

But the development team have been building their projects using MSBuild for a while and I am not allowed to add or remove any project (containing the XAML and dlls) to their solution. I can build the solution using XAML, but in future if there is a need to modify properties of the custom activities it will turn out to be a lot of work to check out the XAML, add the dlls to a dummy project, make the modification and replace the previous XAML file with the new one.

Srikanth Srinivasan United States |

2/4/2011 8:15:30 AM #

Ewald Hofman

There are 2 solutions: Use the custom path in the build controller, or install the assemblies in the gac.

Ewald Hofman Netherlands |

4/24/2011 9:34:18 AM #

SS

Hi Ewald -
This walk thru is useful.
I'm into the same trouble now. Developed a custom activity library, reused the custom activity in the build process template as well.
Now when I distribute that customized build process template, one of the custom activity alone is not getting loaded in a new machine. Showing a red x in the build process template for that activity.
I'd attempted to put that assembly into GAC and into one of the probing paths as well. None seems to be working.
Any post on how to distribute a custom build process template?

Thanks,
--SS

SS India |

5/31/2011 8:22:08 AM #

trackback

Ewald’s posts on TFS Build 2010

Ewald Hofman , an ALM MVP, has written a great series of blog posts on Team Build in Team Foundation Server 2010.  The 2010 release introduces Windows Workflow as the overall orchestrator of the build process.  Ewald walks you through quite a few topics related to this and the other new features.  Check it out! Part 1: Introduction Part 2: Add arguments and variables Part 3: Use more complex arguments Part 4: Create your own activity Part 5: Increase AssemblyVersion Part 6: Use custom type for an argument Part 7: How is the custom assembly found Part 8: Send information to the build log Part 9: Impersonate activities (run under other credentials) Part 10: Include Version Number in the Build Number Part 11: Speed up opening my build process template Part 12: How to debug my custom activities Part 13: Get control over the Build Output Part 14: Execute a PowerShell script Part 15: Fail a build based on the exit code of a console application Part 16: Specify the relative reference path Technorati Tags: tfs 2010 , team build , windows workflow

Buck Hodges |

3/15/2013 6:19:22 AM #

pingback

Pingback from ryanmelena.com

TFS Build Definition – Custom Type with OOTB List Editor | Ryan's Happy Place

ryanmelena.com |

11/22/2013 2:16:22 AM #

pingback

Pingback from ask.techwikihow.com

any work around for not including custom activities in build controller | TechwikiHow

ask.techwikihow.com |

3/11/2014 10:42:00 PM #

pingback

Pingback from idea.creativelabs.biz

[Из песочницы] Последовательности построений в TFS » CreativLabs

idea.creativelabs.biz |

Comments are closed

Powered by BlogEngine.NET 1.6.1.0
Theme by Mads Kristensen


ClusterMap

Statistics

Statistics created at 09 Sep 2009

121 posts
488 comments
324 raters
1862038 visit (1043 per day)
15 users online

Recent comments

Comment RSS