views:

161

answers:

4

Hi all,

I'm trying to create a CustomActivity to run after each successful build.

I've followed the exact steps of several tutorials

  1. http://blogs.blackmarble.co.uk/blogs/rfennell/archive/2010/03/08/lessons-learnt-building-a-custom-activity-to-run-typemock-isolator-in-vs2010-team-build.aspx

  2. http://www.ewaldhofman.nl/post/2010/04/29/Customize-Team-Build-2010-e28093-Part-4-Create-your-own-activity.aspx

  3. http://www.dotnetcurry.com/ShowArticle.aspx?ID=522&AspxAutoDetectCookieSupport=1

And all have lead me to the same result - The build fails after several seconds with this error:

TF215097: An error occurred while initializing a build for build definition 
\MyCompany\Dev - Client: Cannot create unknown type '{clr-
namespace:BuildTasks.Activities;assembly=BuildTasks}TFSBuildLocalizer'.

I came down to a point where I have removed all custom references I had in the CodeActivity project and commented out all of the code.

I have added the output dll to the TFS, and I have the following post build script in the project's properties:

"$(DevEnvDir)\TF.exe" checkout "$/MyCompany/Development/Djenne/Dev/Tools/BuildProcess/Output/$(TargetFileName)"
copy /Y "$(TargetPath)" "C:\tfs2010\MyCompany\Dev\Tools\BuildProcess\Output\$(TargetFileName)"
"$(DevEnvDir)\TF.exe" checkin "$/MyCompany/Development/Djenne/Dev/Tools/BuildProcess/Output/$(TargetFileName)"

I've made sure that the namespace in the workflow xaml is correct for the custom CodeActivity.

I have no idea what else can I try,

Please help!

Thanks,

EDIT: I'm adding more descriptions about what I've already tried:

The CodeActivity class already have the attribute:

[BuildActivity(HostEnvironmentOption.All)]

The CodeActivity class is contained inside an Activity Library project. Here is the ProjectTypeGuids tag inside the csproj file:

<ProjectTypeGuids>{32f31d43-81cc-4c15-9de6-3fc5453562b6};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>

In the custom workflow xaml I've added my CodeActivity right after "Get Impacted Tests, Index Sources and Publish Symbols"

I currently don'e have any InArgument nor OutArgument in my CodeActivity.

These are the references in my CodeActivity project:

  • Microsoft.CSharp
  • Microsoft.TeamFoundation.Build.Client
  • System
  • System.Activities
  • System.Core
  • System.Data
  • System.Data.DataSetExtensions
  • System.Xaml
  • System.Xml
  • System.Xml.Linq
  • WindowsBase

In "Build Controller Properties" I have set the "Version control path to custom assemblies" with the same TFS path as my post build script: $/MyCompany/Development/Djenne/DEV/Tools/BuildProcess/Output

In my Build Definition I've set "Build process template" with my custom workflow xaml.

Thank you guys for the answers, do you have any more thoughts? Thanks

A: 

The problem may be related to the output dll being in TFS.

What could happen is the following:

  • TFS does a get latest
  • The output dll is fetched and is read only
  • TFS tries to build
  • The build tries to write to the dll
  • Since the dll is read only you get an exception
Shiraz Bhaiji
Why would the TFS try to write on the dll???Besides, in that case the exception should've been some kind of IO exception and not "Cannot create unknown type"Don't you think?
Captain
Not TFS, the build, it builds the source code and outputs the dll to the same location as the dll that is checked in to TFS. It is very often that the error messages from TFS are totally wrong
Shiraz Bhaiji
Ok, so what can I do to fix this?
Captain
Move the checkout from postbuild to prebuild, this will make the file writable
Shiraz Bhaiji
A: 

You have to decorate your class with the BuildActivity attribute. See http://www.ewaldhofman.nl/post/2010/05/27/Customize-Team-Build-2010-e28093-Part-7-How-is-the-custom-assembly-found.aspx at the bottom. There is an UPDATE section with more information.

Ewald Hofman
Ewald, I already have this attribute.
Captain
+1  A: 

Where is assembly of your CustomActivity? You must add this assembly to source control and introduce it to the Build Controller you are using. For this:

  1. Right click on Builds node.
  2. Select Manage build controllers.
  3. Click properties.
  4. In the "Version control path to custom assemblies" section, introduce your assembly.
afsharm
afsharm, I already did this.
Captain
@Captain, Are you sure you have checked-in that latest assembly?
afsharm
A: 

Ok, I got this thing figured out.

Here's what worked for me:

I've installed my dll to the GAC in the build server, ran the build and suddenly it worked!

gacutil.exe /i buildtasks

Afterwards, I've uninstalled the dll from the GAC, and it keeps working even still.

gacutil.exe /u buildtasks

Another thing, my project had several references which I also had to checkin in the same directory as the CodeActivity dll itself. So to do that I've changed my project's post build script:

cd "C:\tfs2010\Djenne\Dev\Tools\BuildProcess\Output\"
"$(DevEnvDir)\TF.exe" checkout "$/TradeNetworks/Development/Djenne/Dev/Tools/BuildProcess/Output/*.*"
xcopy "$(TargetDir)*.*" "C:\tfs2010\Djenne\Dev\Tools\BuildProcess\Output\" /E /R /C /Y

The only thing left to do now is to figure out how to debug this damn thing. But that's an issue for another question.

Thanks to everybody who helped,

Hope this will help anyone in the future as well.

EDIT:

One more thing I've noticed is every time I edit my custom workflow, it regenerates the xaml and removes the ";assembly=BuildTasks" suffix from the custom CodeActivity namespace (xmlns). So after every change I need to edit the xaml to fix it over and over again, otherwise the same error reoccurres.

Captain