Quantcast
Channel: MS and Team Build – Automation Planet
Viewing all articles
Browse latest Browse all 33

Create a TFS Build Custom Activity to Read From File

$
0
0

I needed to create a Custom Activity that read from XML file and display the values on the Build log.

It’s very easy and I will not re-write how to do the basic Custom Activity, but if you are not familiar with that, you can see the following link:
Use and develop custom build process activities

Here, I needed to add OutArgument to return the value that I got from reading the file, I will got the value from the file and assign that value to OutArgument.
OutArguemnt in TFS Custom activity

After that, I built the project and distribute the library (DLL) under source control where the build controller point for the custom assemblies, see the previous link for the MSDN on how to do that.

Open your process template that you want to use the new custom activity and Right-click on the Toolbox and browse to the created library as the following image.
Add custom activity for The Visual Studio Toolbox

Drag and drop your new custom activity, declare a new variable (MyValue) to hold the return value from the reading process as the following image.
ReadFromXML Activity

The Build summary will be as the following image.
Build Summary

The build log will be as the following image.
Build Log

 

Make the activity return list of string

We will need to define OutArgument as List<string> and assign that in the execute method
OutArgument as list of string

Declare a variable (MyValue) but this time the type is List<string> too
Drag and drop For each Activity of string and print each item in the list as the followingReadFromXML Activity for list of string

 

The Build summary will be as the following image.
Build Summary for list of string


Viewing all articles
Browse latest Browse all 33

Trending Articles