SlideShare a Scribd company logo
1 of 54
Tfs 2010 Build – Extend the base build Ricci Gian Maria alkampfer@nablasoft.com http://blogs.ugidotnet.org/rgm http://www.codewrecks.com
MsBuild Activity Use an MsBuild Activity to launch a MsBuild project
MsBuild Activity Use a MSBuild Activity to call MSBuild wrapper around a Custom MsBuild task
MsBuild Activity Use a MSBuild Activity to call MSBuild wrapper around a MsBuild task
MsBuild script isinserted in a subdirectoryof the source controlpathof the project. Itis a simpleMsBuildFile.
The project file is a simplemsbuild file, it can contain standard msbuildtasks, or custom tasks.  All custom tasks are included in the source control system and can bereferencedby relative path.
Locate the point in the workflowwhereyouwanttoexecute the custom msbuild project, and dropanMsBuildActivity.
The mostimportantpropertyis the Projectthatcontains the pathto the custom MsBuild project file thatneedstobeexecuted
To pass parameterto custom action, youneedtouse the /propertyswitchofMsBuildcommandline, allpropertiesneededbytasks inside the MsBuild file shouldbepassedthis way.
Configure the restof the MsBuildaction, specifylogFileDropLocationtospecifywhere the logfileneedstobelocated, specifyTargetstobuild, and give a UserFriendly display nameto the action.
At the end of the build, the log ispresent in the same directory of the mainMsBuild log file. In the log file you can seeall the output of the custom task, in thisexampleyou can see the xml answeroftwitter service.
MsBuildActivitytointeractwithprojects UsingMsBuildactivityisnotonlyusefultorunCustomTasks MsBuildis the engineusedto compile projects You can useMsBuildtodeploy a project withClickOnce or todeploy a database project MsBuild can beruneasilyfromcommandline.
Deploy a database project  Locate the pointwhereyouwant the deployto take place, I placedafter test run, and I deployonlyif the compilation phase and test phase are bothgood. The CovertWorkspaceItempermits me tospecify the database project using a source controlpath, thatwillbeconverted in localpath. I alsocreated a dbProjectvariableusedtostore the output of the ConvertWorkspaceItem
Todeploy a database youneedtospecify target Deploy, do notforgettospecify a logFiletoverify the outcomeof the task. All the optionsshouldbespecifiedwithCommandLineArguments "/p:TargetDatabase=NorthwindTest" + " /p:""DefaultDataPath=C:ProgramFilesMicrosoft SQL ServerMSSQL10.SQL2008MSSQLDATA""" + " /p:""TargetConnectionString=Data Source=10.0.0.99QL2008,49400%3Buser=sa%3Bpwd=Pa$$w0rd""" + " /p:DeployToDatabase=true"
As for custom MsBuild task, during the build the output file is the best way tounderstandwhatishappenedduring the build.
Custom Activity Create a Custom Code Activity
Custom Activity Write a custom Workflow Activity
Custom Activity Write a custom Workflow Activity
The assemblies with your Custom Activities should be located in a specific path of the Source Control System. You have only one location where to store your customization, but this is usually a good practice.
Create a custom Code Activity that does the task.
Custom activityinheritsfromCodeActivity, ithas a coupleofattributestobeused inside the buildworkflow, and declaresall Input propertiesusingInArgument<string>class.
Include a custom action in a workflow Create a project with the Custom Action Include a test project whereyouload the buildworkflow (I usually create a branchof the file) Nowyou are abletodrop the Custom Activity inside the workflow Alternativelyyou can simplyedit the workflow file withan XML Editor
Whenyou include the workflow inside a project, contained in the samesolutionthatcontainsalsoyour Custom Activity, you are abletoinsert the custom activity inside the workflow.
Youcannot open anymore the xamlworkflow, in the originalBuildProcessTemplate folder. You can stilledititwithan XML Editor.
Thanksto custom activityyouhave a better design experience, all input parameters are passed in a clear and coincise manner, you don’t needtouseMsBuildcommandline /parameteroption
Logging inside a Custom Activity Since the buildisnotruninteractively, a good log is the best optiontounderstandwhatisgone wrong in case ofanerror. Log asmuch information asyou can, to help people identify the real cause of the failure. Use log levelwithgreat care, so you can choosefrom the mainworkflow the verbosityof the actionduring the build.
Withthissimplemethodyou can add a log message in the build output. The BuildMessageImportanceidentify the importanceof the log, it can havethreevalue: High, Low, and Normal.
You can choose the BuildVerbosityfrom the Argumentsof the build, withthisoptionyou can decide wichlevelofLogswill flow into the build log. Ifyouusethisparameterwith care, you can avoidtoclutterbuild output withunusefulmessages, butyou can raise the verbosity in case ofanerror, tobetterunderstandwhatisgone wrong.
In the build log detail, each action automatically logs its name when it is executed.  If the action create a log with the aforementioned method, the message is inserted after the action, the indentation helps to understand the action the message belongs to.
Differenttypeof log You can log not only simple messages but also warning and errors Both of them are inserted with the BuildInformationRecord class but they are different from a simple lot
A warning is reported in the Build Summary, inside Other Errors and Warnings section They are more important than log messages, and they should be used to communicate messages that needs immediate user attenction
Log Messages, even with High BuildMessageImportance, are always showed like normal messages. Warnings have a warning icon that differentiates them from standard messages even in the detailed build
When you issue a BuildError, the entire build is considered in Partially Failed State.  The error is showed in the View Summary as well in the View Log, with a red icon to identify a real error that is happened during the build.
Custom Activity that wraps a Custom Task Create a Custom Code Activity that internally uses a Custom Task
Wrap MsBuild task in Custom Activity Wrap MsBuild custom task in a custom Workflow Activity
Wrap MsBuild task in Custom Activity Wrap MsBuild custom task in a custom Workflow Activity
This is an example of a Custom MsBuild Task that reduces the size of an Url with TinyUrl service. We have a couple of problems here. The first one is how to grab the value of the output property TinedUrland pass it back to workflow environment; the other one is how to “fool” the CustomTask that he is running inside a MsBuild environment. Another important aspect, is how to include log messages issued by the Custom Task inside the build log, and not in a txt file in drop folder
Custom Activity IBuildEngine Logs Workflow BuildEngine CustomTask Property CustomTask A CustomTask interact with the MsBuild environment through an interface called IBuildEngine. In the previous code, the call to Log.LogMessage flow into a concrete implementation of IBuildEngine. The trick to intercept log messages is to build a custom implementation of IBuildEngine
The WorkflowBuildEngine class implements IBuildEngine and contains a CodeActivityContext that is used to interact with the workflow Log functions are implemented with a simple call to Utility function seen before. With this trick all call to Log inside the Custom Activity will flow into the workflow log.
This activity inherits from CodeActivity<T> where the type argument indicates the return value Inside the activity I create an instance of the Custom Task, populate all input properties, as well as the BuildEngine property. Then I call the execute method and if it returns false (the custom task encounter errors during execution) I log an error, and finally I returned the value of the output property of the Custom Task
You get a better design experience, property are populated through the designer. You can assign the value of result property to a property of the Workflow, you are able to grab output properties of Custom Msbuild Task. Remember to deploy the dll with the custom task in the same folder as the assembly that contains custom action
All Log.LogXX calls made inside the MsBuild Custom Task are intercepted and transferred to Workflow. Not only messaged, but also warnings issued by Custom Task are correctly identified as Warning in the build result. With this technique you do not need to look at the text log file to understand what is gone wrong during the execution of the Custom Task.
Custom activity Instead of code something, create a new activity composing multiple simple activity to accomplish a complex task Es. Deploy database, instead of using directly MsBuildActivity
Using “arguments” you declare all input arguments needed by your action.  In the property windows you can set type, direction and IsRequired property, you can also specify a default value
This example shows how to create a custom action that deploy a database project using the same technique seen before. The only difference is that all the steps are included in one action to have a better user experience during customization
Logging is easy, because you can simply use the WriteBuildMessage activity from the “Team Foundation Build Activity” list. The log of database deployment is still done by MsBuild in the standard file located in drop folder.
Instead of using several activities, you can simply drop a single one and you can configure parameter explicitly. Each parameter to the deploy operation is represented by a specific property, and each property can have a default value.
Compare how easily arguments are passed with a Custom Activity respect using directly the MsBuildActivity
Move the logic into a poco class Put the logic inside a POCO class, then build a MsBuild custom task and a Custom Activity
Take the best of both world Extract the logic into a POCO class and create wrappers
Take the best of both world Extract the logic into a POCO class and create wrappers
A real scenario Create a custom build to automate the deployment of a web app in a test server The script deploy the database project and change the directory in IIS to point to the drop folder TFS Update IIS Check In Sync DB Build Server DB Test
You can obtain this from the previous example “Deploy database with Msbuild”. The only added part is another Custom Activity used to change the folder of a site using WMI to communicate with IIS
Extending the build workflow of TFS 2010

More Related Content

What's hot

Introduction to react_js
Introduction to react_jsIntroduction to react_js
Introduction to react_jsMicroPyramid .
 
New Component Patterns in Ember.js
New Component Patterns in Ember.jsNew Component Patterns in Ember.js
New Component Patterns in Ember.jsMatthew Beale
 
React js - The Core Concepts
React js - The Core ConceptsReact js - The Core Concepts
React js - The Core ConceptsDivyang Bhambhani
 
Creating lightweight JS Apps w/ Web Components and lit-html
Creating lightweight JS Apps w/ Web Components and lit-htmlCreating lightweight JS Apps w/ Web Components and lit-html
Creating lightweight JS Apps w/ Web Components and lit-htmlIlia Idakiev
 
React.js and Redux overview
React.js and Redux overviewReact.js and Redux overview
React.js and Redux overviewAlex Bachuk
 
React js programming concept
React js programming conceptReact js programming concept
React js programming conceptTariqul islam
 
React JS and Redux
React JS and ReduxReact JS and Redux
React JS and ReduxGlib Kechyn
 
React js Rahil Memon
React js Rahil MemonReact js Rahil Memon
React js Rahil MemonRahilMemon5
 
Welcome to React & Flux !
Welcome to React & Flux !Welcome to React & Flux !
Welcome to React & Flux !Ritesh Kumar
 
20180518 QNAP Seminar - Introduction to React Native
20180518 QNAP Seminar - Introduction to React Native20180518 QNAP Seminar - Introduction to React Native
20180518 QNAP Seminar - Introduction to React NativeEric Deng
 
Introduction to React JS for beginners | Namespace IT
Introduction to React JS for beginners | Namespace ITIntroduction to React JS for beginners | Namespace IT
Introduction to React JS for beginners | Namespace ITnamespaceit
 
Breaking the Server-Client Divide with Node.js and React
Breaking the Server-Client Divide with Node.js and ReactBreaking the Server-Client Divide with Node.js and React
Breaking the Server-Client Divide with Node.js and ReactDejan Glozic
 
Introduction to React JS for beginners
Introduction to React JS for beginners Introduction to React JS for beginners
Introduction to React JS for beginners Varun Raj
 
Switch to React.js from AngularJS developer
Switch to React.js from AngularJS developerSwitch to React.js from AngularJS developer
Switch to React.js from AngularJS developerEugene Zharkov
 
React for Dummies
React for DummiesReact for Dummies
React for DummiesMitch Chen
 

What's hot (20)

Introduction to react_js
Introduction to react_jsIntroduction to react_js
Introduction to react_js
 
New Component Patterns in Ember.js
New Component Patterns in Ember.jsNew Component Patterns in Ember.js
New Component Patterns in Ember.js
 
React js - The Core Concepts
React js - The Core ConceptsReact js - The Core Concepts
React js - The Core Concepts
 
Creating lightweight JS Apps w/ Web Components and lit-html
Creating lightweight JS Apps w/ Web Components and lit-htmlCreating lightweight JS Apps w/ Web Components and lit-html
Creating lightweight JS Apps w/ Web Components and lit-html
 
React
React React
React
 
React.js and Redux overview
React.js and Redux overviewReact.js and Redux overview
React.js and Redux overview
 
React js programming concept
React js programming conceptReact js programming concept
React js programming concept
 
React JS and Redux
React JS and ReduxReact JS and Redux
React JS and Redux
 
React js Rahil Memon
React js Rahil MemonReact js Rahil Memon
React js Rahil Memon
 
Welcome to React & Flux !
Welcome to React & Flux !Welcome to React & Flux !
Welcome to React & Flux !
 
20180518 QNAP Seminar - Introduction to React Native
20180518 QNAP Seminar - Introduction to React Native20180518 QNAP Seminar - Introduction to React Native
20180518 QNAP Seminar - Introduction to React Native
 
React js
React jsReact js
React js
 
Introduction to React JS for beginners | Namespace IT
Introduction to React JS for beginners | Namespace ITIntroduction to React JS for beginners | Namespace IT
Introduction to React JS for beginners | Namespace IT
 
Breaking the Server-Client Divide with Node.js and React
Breaking the Server-Client Divide with Node.js and ReactBreaking the Server-Client Divide with Node.js and React
Breaking the Server-Client Divide with Node.js and React
 
Introduction to React JS for beginners
Introduction to React JS for beginners Introduction to React JS for beginners
Introduction to React JS for beginners
 
React.js+Redux Workshops
React.js+Redux WorkshopsReact.js+Redux Workshops
React.js+Redux Workshops
 
React JS - Introduction
React JS - IntroductionReact JS - Introduction
React JS - Introduction
 
React js
React jsReact js
React js
 
Switch to React.js from AngularJS developer
Switch to React.js from AngularJS developerSwitch to React.js from AngularJS developer
Switch to React.js from AngularJS developer
 
React for Dummies
React for DummiesReact for Dummies
React for Dummies
 

Similar to Extending the build workflow of TFS 2010

Whats New in MSBuild 3.5 and Team Build 2008
Whats New in MSBuild 3.5 and Team Build 2008Whats New in MSBuild 3.5 and Team Build 2008
Whats New in MSBuild 3.5 and Team Build 2008wbarthol
 
IndexedDB and Push Notifications in Progressive Web Apps
IndexedDB and Push Notifications in Progressive Web AppsIndexedDB and Push Notifications in Progressive Web Apps
IndexedDB and Push Notifications in Progressive Web AppsAdégòkè Obasá
 
How to create an Angular builder
How to create an Angular builderHow to create an Angular builder
How to create an Angular builderMaurizio Vitale
 
.NET Portfolio
.NET Portfolio.NET Portfolio
.NET Portfoliomwillmer
 
Will your code blend? : Toronto Code Camp 2010 : Barry Gervin
Will your code blend? : Toronto Code Camp 2010 : Barry GervinWill your code blend? : Toronto Code Camp 2010 : Barry Gervin
Will your code blend? : Toronto Code Camp 2010 : Barry GervinBarry Gervin
 
Build Your Own Instagram Filters
Build Your Own Instagram FiltersBuild Your Own Instagram Filters
Build Your Own Instagram FiltersTJ Stalcup
 
3 Ways to Get Started with a React App in 2024.pdf
3 Ways to Get Started with a React App in 2024.pdf3 Ways to Get Started with a React App in 2024.pdf
3 Ways to Get Started with a React App in 2024.pdfBOSC Tech Labs
 
Angular - Chapter 4 - Data and Event Handling
 Angular - Chapter 4 - Data and Event Handling Angular - Chapter 4 - Data and Event Handling
Angular - Chapter 4 - Data and Event HandlingWebStackAcademy
 
Advanced Dagger talk from 360andev
Advanced Dagger talk from 360andevAdvanced Dagger talk from 360andev
Advanced Dagger talk from 360andevMike Nakhimovich
 
PVS-Studio in the Clouds: Azure DevOps
PVS-Studio in the Clouds: Azure DevOpsPVS-Studio in the Clouds: Azure DevOps
PVS-Studio in the Clouds: Azure DevOpsAndrey Karpov
 
End To End Build Automation With Team Build
End To End Build Automation With Team BuildEnd To End Build Automation With Team Build
End To End Build Automation With Team Buildwbarthol
 
Rapid Prototyping with TurboGears2
Rapid Prototyping with TurboGears2Rapid Prototyping with TurboGears2
Rapid Prototyping with TurboGears2Alessandro Molina
 
Divide and Conquer – Microservices with Node.js
Divide and Conquer – Microservices with Node.jsDivide and Conquer – Microservices with Node.js
Divide and Conquer – Microservices with Node.jsSebastian Springer
 
Dot Net Fundamentals
Dot Net FundamentalsDot Net Fundamentals
Dot Net FundamentalsLiquidHub
 
We continue checking Microsoft projects: analysis of PowerShell
We continue checking Microsoft projects: analysis of PowerShellWe continue checking Microsoft projects: analysis of PowerShell
We continue checking Microsoft projects: analysis of PowerShellPVS-Studio
 

Similar to Extending the build workflow of TFS 2010 (20)

Whats New in MSBuild 3.5 and Team Build 2008
Whats New in MSBuild 3.5 and Team Build 2008Whats New in MSBuild 3.5 and Team Build 2008
Whats New in MSBuild 3.5 and Team Build 2008
 
IndexedDB and Push Notifications in Progressive Web Apps
IndexedDB and Push Notifications in Progressive Web AppsIndexedDB and Push Notifications in Progressive Web Apps
IndexedDB and Push Notifications in Progressive Web Apps
 
How to create an Angular builder
How to create an Angular builderHow to create an Angular builder
How to create an Angular builder
 
.NET Portfolio
.NET Portfolio.NET Portfolio
.NET Portfolio
 
Will your code blend? : Toronto Code Camp 2010 : Barry Gervin
Will your code blend? : Toronto Code Camp 2010 : Barry GervinWill your code blend? : Toronto Code Camp 2010 : Barry Gervin
Will your code blend? : Toronto Code Camp 2010 : Barry Gervin
 
Build Your Own Instagram Filters
Build Your Own Instagram FiltersBuild Your Own Instagram Filters
Build Your Own Instagram Filters
 
3 Ways to Get Started with a React App in 2024.pdf
3 Ways to Get Started with a React App in 2024.pdf3 Ways to Get Started with a React App in 2024.pdf
3 Ways to Get Started with a React App in 2024.pdf
 
Angular - Chapter 4 - Data and Event Handling
 Angular - Chapter 4 - Data and Event Handling Angular - Chapter 4 - Data and Event Handling
Angular - Chapter 4 - Data and Event Handling
 
Advanced Dagger talk from 360andev
Advanced Dagger talk from 360andevAdvanced Dagger talk from 360andev
Advanced Dagger talk from 360andev
 
PVS-Studio in the Clouds: Azure DevOps
PVS-Studio in the Clouds: Azure DevOpsPVS-Studio in the Clouds: Azure DevOps
PVS-Studio in the Clouds: Azure DevOps
 
End To End Build Automation With Team Build
End To End Build Automation With Team BuildEnd To End Build Automation With Team Build
End To End Build Automation With Team Build
 
Readme
ReadmeReadme
Readme
 
Rapid Prototyping with TurboGears2
Rapid Prototyping with TurboGears2Rapid Prototyping with TurboGears2
Rapid Prototyping with TurboGears2
 
Divide and Conquer – Microservices with Node.js
Divide and Conquer – Microservices with Node.jsDivide and Conquer – Microservices with Node.js
Divide and Conquer – Microservices with Node.js
 
Pratk kambe rac
Pratk kambe racPratk kambe rac
Pratk kambe rac
 
Building richwebapplicationsusingasp
Building richwebapplicationsusingaspBuilding richwebapplicationsusingasp
Building richwebapplicationsusingasp
 
Dot Net Fundamentals
Dot Net FundamentalsDot Net Fundamentals
Dot Net Fundamentals
 
We continue checking Microsoft projects: analysis of PowerShell
We continue checking Microsoft projects: analysis of PowerShellWe continue checking Microsoft projects: analysis of PowerShell
We continue checking Microsoft projects: analysis of PowerShell
 
ASP.NET MVC3 RAD
ASP.NET MVC3 RADASP.NET MVC3 RAD
ASP.NET MVC3 RAD
 
Final ppt
Final pptFinal ppt
Final ppt
 

More from Gian Maria Ricci

Se non sviluppo codice non sto lavorando
Se non sviluppo codice non sto lavorandoSe non sviluppo codice non sto lavorando
Se non sviluppo codice non sto lavorandoGian Maria Ricci
 
Gestire la qualità del codice con Visual Studio, SonarQube ed Azure Devops
Gestire la qualità del codice con Visual Studio, SonarQube ed Azure DevopsGestire la qualità del codice con Visual Studio, SonarQube ed Azure Devops
Gestire la qualità del codice con Visual Studio, SonarQube ed Azure DevopsGian Maria Ricci
 
Migrare da un VCS centralizzato a Git
Migrare da un VCS centralizzato a GitMigrare da un VCS centralizzato a Git
Migrare da un VCS centralizzato a GitGian Maria Ricci
 
Real World Build + Release automation in Azure DevOps
Real World Build + Release automation in Azure DevOpsReal World Build + Release automation in Azure DevOps
Real World Build + Release automation in Azure DevOpsGian Maria Ricci
 
Gestire i rilasci automatici con azure devops
Gestire i rilasci automatici con azure devopsGestire i rilasci automatici con azure devops
Gestire i rilasci automatici con azure devopsGian Maria Ricci
 
Build and release in code with azure devops pipelines
Build and release in code with azure devops pipelinesBuild and release in code with azure devops pipelines
Build and release in code with azure devops pipelinesGian Maria Ricci
 
Azure Pipeline in salsa yaml
Azure Pipeline in salsa yamlAzure Pipeline in salsa yaml
Azure Pipeline in salsa yamlGian Maria Ricci
 
Git gitflow pull requests in devops focused teams
Git gitflow pull requests in devops focused teamsGit gitflow pull requests in devops focused teams
Git gitflow pull requests in devops focused teamsGian Maria Ricci
 
Distribute your code with NUget and build vNext
Distribute your code with NUget and build vNextDistribute your code with NUget and build vNext
Distribute your code with NUget and build vNextGian Maria Ricci
 
Manage your environment with DSC
Manage your environment with DSCManage your environment with DSC
Manage your environment with DSCGian Maria Ricci
 
Introduction to Application insights
Introduction to Application insightsIntroduction to Application insights
Introduction to Application insightsGian Maria Ricci
 
Deploy applications with TFS Build
Deploy applications with TFS BuildDeploy applications with TFS Build
Deploy applications with TFS BuildGian Maria Ricci
 
TFS - Quale source control
TFS - Quale source controlTFS - Quale source control
TFS - Quale source controlGian Maria Ricci
 
Introduction to Visual Studio Online
Introduction to Visual Studio OnlineIntroduction to Visual Studio Online
Introduction to Visual Studio OnlineGian Maria Ricci
 
Come Organizzare il proprio Team Project
Come Organizzare il proprio Team ProjectCome Organizzare il proprio Team Project
Come Organizzare il proprio Team ProjectGian Maria Ricci
 

More from Gian Maria Ricci (20)

Se non sviluppo codice non sto lavorando
Se non sviluppo codice non sto lavorandoSe non sviluppo codice non sto lavorando
Se non sviluppo codice non sto lavorando
 
Gestire la qualità del codice con Visual Studio, SonarQube ed Azure Devops
Gestire la qualità del codice con Visual Studio, SonarQube ed Azure DevopsGestire la qualità del codice con Visual Studio, SonarQube ed Azure Devops
Gestire la qualità del codice con Visual Studio, SonarQube ed Azure Devops
 
Migrare da un VCS centralizzato a Git
Migrare da un VCS centralizzato a GitMigrare da un VCS centralizzato a Git
Migrare da un VCS centralizzato a Git
 
Real World Build + Release automation in Azure DevOps
Real World Build + Release automation in Azure DevOpsReal World Build + Release automation in Azure DevOps
Real World Build + Release automation in Azure DevOps
 
Gestire i rilasci automatici con azure devops
Gestire i rilasci automatici con azure devopsGestire i rilasci automatici con azure devops
Gestire i rilasci automatici con azure devops
 
Build and release in code with azure devops pipelines
Build and release in code with azure devops pipelinesBuild and release in code with azure devops pipelines
Build and release in code with azure devops pipelines
 
Azure Pipeline in salsa yaml
Azure Pipeline in salsa yamlAzure Pipeline in salsa yaml
Azure Pipeline in salsa yaml
 
Git gitflow pull requests in devops focused teams
Git gitflow pull requests in devops focused teamsGit gitflow pull requests in devops focused teams
Git gitflow pull requests in devops focused teams
 
Distribute your code with NUget and build vNext
Distribute your code with NUget and build vNextDistribute your code with NUget and build vNext
Distribute your code with NUget and build vNext
 
Manage your environment with DSC
Manage your environment with DSCManage your environment with DSC
Manage your environment with DSC
 
Introduction to Application insights
Introduction to Application insightsIntroduction to Application insights
Introduction to Application insights
 
Git branching model
Git branching modelGit branching model
Git branching model
 
Deploy applications with TFS Build
Deploy applications with TFS BuildDeploy applications with TFS Build
Deploy applications with TFS Build
 
TFS - Quale source control
TFS - Quale source controlTFS - Quale source control
TFS - Quale source control
 
Branch model in Git
Branch model in GitBranch model in Git
Branch model in Git
 
Introduction to Visual Studio Online
Introduction to Visual Studio OnlineIntroduction to Visual Studio Online
Introduction to Visual Studio Online
 
Git si o Git No
Git si o Git NoGit si o Git No
Git si o Git No
 
Testing
TestingTesting
Testing
 
Come Organizzare il proprio Team Project
Come Organizzare il proprio Team ProjectCome Organizzare il proprio Team Project
Come Organizzare il proprio Team Project
 
Git Perchè Usarlo
Git Perchè UsarloGit Perchè Usarlo
Git Perchè Usarlo
 

Recently uploaded

The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 

Recently uploaded (20)

The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 

Extending the build workflow of TFS 2010

  • 1. Tfs 2010 Build – Extend the base build Ricci Gian Maria alkampfer@nablasoft.com http://blogs.ugidotnet.org/rgm http://www.codewrecks.com
  • 2. MsBuild Activity Use an MsBuild Activity to launch a MsBuild project
  • 3. MsBuild Activity Use a MSBuild Activity to call MSBuild wrapper around a Custom MsBuild task
  • 4. MsBuild Activity Use a MSBuild Activity to call MSBuild wrapper around a MsBuild task
  • 5. MsBuild script isinserted in a subdirectoryof the source controlpathof the project. Itis a simpleMsBuildFile.
  • 6. The project file is a simplemsbuild file, it can contain standard msbuildtasks, or custom tasks. All custom tasks are included in the source control system and can bereferencedby relative path.
  • 7. Locate the point in the workflowwhereyouwanttoexecute the custom msbuild project, and dropanMsBuildActivity.
  • 8. The mostimportantpropertyis the Projectthatcontains the pathto the custom MsBuild project file thatneedstobeexecuted
  • 9. To pass parameterto custom action, youneedtouse the /propertyswitchofMsBuildcommandline, allpropertiesneededbytasks inside the MsBuild file shouldbepassedthis way.
  • 10. Configure the restof the MsBuildaction, specifylogFileDropLocationtospecifywhere the logfileneedstobelocated, specifyTargetstobuild, and give a UserFriendly display nameto the action.
  • 11. At the end of the build, the log ispresent in the same directory of the mainMsBuild log file. In the log file you can seeall the output of the custom task, in thisexampleyou can see the xml answeroftwitter service.
  • 12. MsBuildActivitytointeractwithprojects UsingMsBuildactivityisnotonlyusefultorunCustomTasks MsBuildis the engineusedto compile projects You can useMsBuildtodeploy a project withClickOnce or todeploy a database project MsBuild can beruneasilyfromcommandline.
  • 13. Deploy a database project Locate the pointwhereyouwant the deployto take place, I placedafter test run, and I deployonlyif the compilation phase and test phase are bothgood. The CovertWorkspaceItempermits me tospecify the database project using a source controlpath, thatwillbeconverted in localpath. I alsocreated a dbProjectvariableusedtostore the output of the ConvertWorkspaceItem
  • 14. Todeploy a database youneedtospecify target Deploy, do notforgettospecify a logFiletoverify the outcomeof the task. All the optionsshouldbespecifiedwithCommandLineArguments "/p:TargetDatabase=NorthwindTest" + " /p:""DefaultDataPath=C:ProgramFilesMicrosoft SQL ServerMSSQL10.SQL2008MSSQLDATA""" + " /p:""TargetConnectionString=Data Source=10.0.0.99QL2008,49400%3Buser=sa%3Bpwd=Pa$$w0rd""" + " /p:DeployToDatabase=true"
  • 15. As for custom MsBuild task, during the build the output file is the best way tounderstandwhatishappenedduring the build.
  • 16. Custom Activity Create a Custom Code Activity
  • 17. Custom Activity Write a custom Workflow Activity
  • 18. Custom Activity Write a custom Workflow Activity
  • 19. The assemblies with your Custom Activities should be located in a specific path of the Source Control System. You have only one location where to store your customization, but this is usually a good practice.
  • 20. Create a custom Code Activity that does the task.
  • 21. Custom activityinheritsfromCodeActivity, ithas a coupleofattributestobeused inside the buildworkflow, and declaresall Input propertiesusingInArgument<string>class.
  • 22. Include a custom action in a workflow Create a project with the Custom Action Include a test project whereyouload the buildworkflow (I usually create a branchof the file) Nowyou are abletodrop the Custom Activity inside the workflow Alternativelyyou can simplyedit the workflow file withan XML Editor
  • 23. Whenyou include the workflow inside a project, contained in the samesolutionthatcontainsalsoyour Custom Activity, you are abletoinsert the custom activity inside the workflow.
  • 24. Youcannot open anymore the xamlworkflow, in the originalBuildProcessTemplate folder. You can stilledititwithan XML Editor.
  • 25. Thanksto custom activityyouhave a better design experience, all input parameters are passed in a clear and coincise manner, you don’t needtouseMsBuildcommandline /parameteroption
  • 26. Logging inside a Custom Activity Since the buildisnotruninteractively, a good log is the best optiontounderstandwhatisgone wrong in case ofanerror. Log asmuch information asyou can, to help people identify the real cause of the failure. Use log levelwithgreat care, so you can choosefrom the mainworkflow the verbosityof the actionduring the build.
  • 27. Withthissimplemethodyou can add a log message in the build output. The BuildMessageImportanceidentify the importanceof the log, it can havethreevalue: High, Low, and Normal.
  • 28. You can choose the BuildVerbosityfrom the Argumentsof the build, withthisoptionyou can decide wichlevelofLogswill flow into the build log. Ifyouusethisparameterwith care, you can avoidtoclutterbuild output withunusefulmessages, butyou can raise the verbosity in case ofanerror, tobetterunderstandwhatisgone wrong.
  • 29. In the build log detail, each action automatically logs its name when it is executed. If the action create a log with the aforementioned method, the message is inserted after the action, the indentation helps to understand the action the message belongs to.
  • 30. Differenttypeof log You can log not only simple messages but also warning and errors Both of them are inserted with the BuildInformationRecord class but they are different from a simple lot
  • 31. A warning is reported in the Build Summary, inside Other Errors and Warnings section They are more important than log messages, and they should be used to communicate messages that needs immediate user attenction
  • 32. Log Messages, even with High BuildMessageImportance, are always showed like normal messages. Warnings have a warning icon that differentiates them from standard messages even in the detailed build
  • 33. When you issue a BuildError, the entire build is considered in Partially Failed State. The error is showed in the View Summary as well in the View Log, with a red icon to identify a real error that is happened during the build.
  • 34. Custom Activity that wraps a Custom Task Create a Custom Code Activity that internally uses a Custom Task
  • 35. Wrap MsBuild task in Custom Activity Wrap MsBuild custom task in a custom Workflow Activity
  • 36. Wrap MsBuild task in Custom Activity Wrap MsBuild custom task in a custom Workflow Activity
  • 37. This is an example of a Custom MsBuild Task that reduces the size of an Url with TinyUrl service. We have a couple of problems here. The first one is how to grab the value of the output property TinedUrland pass it back to workflow environment; the other one is how to “fool” the CustomTask that he is running inside a MsBuild environment. Another important aspect, is how to include log messages issued by the Custom Task inside the build log, and not in a txt file in drop folder
  • 38. Custom Activity IBuildEngine Logs Workflow BuildEngine CustomTask Property CustomTask A CustomTask interact with the MsBuild environment through an interface called IBuildEngine. In the previous code, the call to Log.LogMessage flow into a concrete implementation of IBuildEngine. The trick to intercept log messages is to build a custom implementation of IBuildEngine
  • 39. The WorkflowBuildEngine class implements IBuildEngine and contains a CodeActivityContext that is used to interact with the workflow Log functions are implemented with a simple call to Utility function seen before. With this trick all call to Log inside the Custom Activity will flow into the workflow log.
  • 40. This activity inherits from CodeActivity<T> where the type argument indicates the return value Inside the activity I create an instance of the Custom Task, populate all input properties, as well as the BuildEngine property. Then I call the execute method and if it returns false (the custom task encounter errors during execution) I log an error, and finally I returned the value of the output property of the Custom Task
  • 41. You get a better design experience, property are populated through the designer. You can assign the value of result property to a property of the Workflow, you are able to grab output properties of Custom Msbuild Task. Remember to deploy the dll with the custom task in the same folder as the assembly that contains custom action
  • 42. All Log.LogXX calls made inside the MsBuild Custom Task are intercepted and transferred to Workflow. Not only messaged, but also warnings issued by Custom Task are correctly identified as Warning in the build result. With this technique you do not need to look at the text log file to understand what is gone wrong during the execution of the Custom Task.
  • 43. Custom activity Instead of code something, create a new activity composing multiple simple activity to accomplish a complex task Es. Deploy database, instead of using directly MsBuildActivity
  • 44. Using “arguments” you declare all input arguments needed by your action. In the property windows you can set type, direction and IsRequired property, you can also specify a default value
  • 45. This example shows how to create a custom action that deploy a database project using the same technique seen before. The only difference is that all the steps are included in one action to have a better user experience during customization
  • 46. Logging is easy, because you can simply use the WriteBuildMessage activity from the “Team Foundation Build Activity” list. The log of database deployment is still done by MsBuild in the standard file located in drop folder.
  • 47. Instead of using several activities, you can simply drop a single one and you can configure parameter explicitly. Each parameter to the deploy operation is represented by a specific property, and each property can have a default value.
  • 48. Compare how easily arguments are passed with a Custom Activity respect using directly the MsBuildActivity
  • 49. Move the logic into a poco class Put the logic inside a POCO class, then build a MsBuild custom task and a Custom Activity
  • 50. Take the best of both world Extract the logic into a POCO class and create wrappers
  • 51. Take the best of both world Extract the logic into a POCO class and create wrappers
  • 52. A real scenario Create a custom build to automate the deployment of a web app in a test server The script deploy the database project and change the directory in IIS to point to the drop folder TFS Update IIS Check In Sync DB Build Server DB Test
  • 53. You can obtain this from the previous example “Deploy database with Msbuild”. The only added part is another Custom Activity used to change the folder of a site using WMI to communicate with IIS