Test TFS Build Workflow Locally - tfs

I maintain our build process on our TFS 2012 system.
Up till now I've been making changes locally to a solution that generates our custom activity DLLs. These DLLs are checked into TFS and are used by the build controllers and agents for the custom activities in our custom build template.
For all of my code and workflow activities I have a unit test library that I can locally run to put in some base test values. While this gives me a good idea at how my custom tasks will run it is not optimal.
What I would like to be able to do is run the entire build definition. Is there a way to test the whole build process locally so that I can be sure that my changes to the workflow are acceptable before checking in and kicking off a build? Right now my builds take between 30 and 40 minutes to complete and I would like to be able to start, monitor, debug, and stop the build locally without occupying one of our agents.
Edit
Another method for me to solve this problem is to come up with some manner to execute the workflow that is the build template locally. Has anyone been able to do this?

Take a look at the Ranger Build Customization Guidance. There is a HOL for doing a lot of this. It doesn't look like it is in v2 so take a look at v1.2.
http://vsarbuildguide.codeplex.com/releases/view/87995

If I am understanding the issue correctly, one way to do this may be:
Install a build agent locally and register it with the TFS Build Controller.
Give the new agent a custom tag so it doesn't get assigned other builds from the queue
Shelve your changeset
In VS, right click the build definition you want, and select queue new build. A "Queue Build" window will open
Under the general tab, "What do you want to build", select your shelveset.
Under Parameters tab ->Advanced -> agent settings, enter your agent's tag.
Click queue.

I accomplish this using a modified version of #malexander recommendation.
Create a code branch in TFS, commit your changes there, especially the changes to your custom activity DLL's (compiled binaries, not just source).
Install a TFS Build Controller and Build Agent locally, registering the controller with your TFS server.
Configure your new local controller to use your modified custom activity DLL's, stored in your new TFS code branch. Team Explorer > Builds > Actions > Manage Build Controllers >
(select your new local controller) > Properties > Version control
path to custom assemblies
4.
Queue a new build, from an existing TFS build definition: change its controller to use your new local controller.
The new build will execute on your local controller/agent, using your modified custom activity DLL's, without interfering/restarting your production agents.
Also: since you're in your own code branch, you can commit debug versions of your custom activity DLL's, without impacting your production agents.

Related

TFS 2010 Controller integration to TFS 2015

We have migrated TFS2010 to TFS2015sp3 and we would like to use the existing TFS2010 build controller & agents (XAML) with TFS2015.
As a sample test, we did a clone of the existing TFS2010 controller and on the new machine we pointed the Project collections to the new TFS2015 URL.
I see the build controller and Agents in running state, but when I queue the build it keeps on waiting for build agent, even though the agents are online.
TFS 2015 still support XAML Builds as long as you use TFS2010/TFS2013 XAML Build controller.
Please make sure your build control version are the same as build agent version. So if you are using TFS2010 build control, you should also using TFS2010 build agent.
You could also create a new build control TFS2015 and build agent 2015, test if the build works properly.
Even though the build agent and control is online, you should also double confirm you have selected the right one in the drop list when you queue the build.
Besides, please also verify that your controller has "Maximum number of concurrently running builds" set to a number higher than 0. The default to number of agents can sometimes go wrong.
You set this on the controller properties in the TFS admin console.
You can also try remove the agent from the controller and add it again.

TFS, Jenkins and how to update work items with build numbers

We are using TFS and the TFS Build Service. We are considering to migrate the Build service to Jenkins but we came across some issues. According to this site, there are some things that do not work very well with the TFS and Jenkins plugins. All of them we use a lot:
Associated Change sets – Team Build automatically associates a list of change sets that are included in the build
Associated Work Items – Team Build analysis the relationships and also associates Work Items with a build. Indeed it walks the work item tree (parent) and maintains that association in the chain.
Is this still true? We have this scenario:
A developer checks in a code that fix a bug or resolve a User Story. It does that by associating his check in with the work item ID.
His check in triggers a build that will associate the work item with his changeset. For bugs, the build will update the "Integrated in Build" field with the build number. We use this field to know in witch version the bug was fixed.
Is there any way to make Jenkins behave and do what TFS build service does?
Another option is to mix the two using dummy builds on the TFS side that set the records straight and kick-off the Jenkins' builds. Some hints
How to trigger Jenkins builds remotely and to pass parameters and “Fake” a TFS Build.
This approach requires a bit of effort but has many advantages:
No big-bang, use Jenkins opportunistically
Can continue using existing builds
Having a build identifier in TFS allows you an overall monitoring and to use the Test features
I have a VSTS build definition for one of our projects that requires jenkins to build, but we still have all our other products using VSTS natively. To maintain consistency, this build definition triggers a jenkins build. We configured the build definition to not sync code as jenkins will download it (save time) and not to publish the artifacts back to the agent (i have another script for that found here). This allows developers to continue to use git as normal, and the build/release process is consistent with our other products. Along with task tracking and such.

Customize TFS Build to include only specific files

I have a solution file with multiple projects that I am trying to configure for continuous integration on a development server using Team Foundation Server. I would like to customize this to only deploy the changes that were checked in.
Scenario example
Projects
My Project (MVC app)
Logic Layer
A user checks in a new Home.cshtml file and updates a code file in the Logic Layer. I would like to configure the automated build to just build the following package:
My Project
bin/MyLogic.dll
Views/Home.cshtml
What steps are done to achieve this scenario?
You want an incremental build, though I don't recall if it was supported back in TFS 2010.
Try configuring the build to not clean the workspace. Set the "Clean Workspace" property in the "Basic" section to "None".
Then, it will keep the binaries from the previous build, and, just like Visual Studio, will only build targets for which the inputs have changed.

How can I make a desktop build in TFS 2010?

I know that the short answer is "you can't". Desktop builds are no longer a part of TFS 2010.
However, I figure that I can somehow, if I install a build agent on my machine, and direct the WF to not get the latest version or a shelveset, and use the existing workspace, I should be able to fake it.
The problem is that between the theory and practice is a large gap in my knowledge. Can anyone think of a way this could work?
What is it, exactly, that you're trying to accomplish? Why not just setup a build agent on your machine and configure an incremental build to run on it? You could pass shelvesets into it via the Queue Build dialog or use a separate branch to keep your sources separate from the rest of your teams.
I finally came up with a solution:
A client that wants to build locally (i.e. desktop-builds) needs to install a Build Controller and Build Agent on his desktop machine. Then he needs to pick that controller for the build.
In the build template, the Get activity needs to be deleted, and the Create Workspace activity needs to be replaced with a Get Workspace, to use an existing one.
Finally, remove the command to copy to a drop folder. You're building locally. Not necessary.
Assaf

The easiest way to test TFS2010 build template

I'm currently working on creating a build template for TFS2010 builds. However, I notice that I'm currently 'spamming' the source control with every change I make to the template (and lots more for all the fixes for those changes).
I wonder what the easiest way is to test the build templates I'm creating?
Is there a way to change the template file and custom activity dlls that doesn't involve checking them in?
I currently have a build controller and agent running on my developer machine, which I'm using to test the template (test = start a build and hope for less errors than last time).
Why is 'spamming' a problem? Anyway, I have a separate Team Project for doing this kind of work, that way I can check in to my hearts content without affecting the developers who need to have a stable build. once I've done my testing I check the template in to the team project(s) used by the developers.
I want to test my builds against the teams latest code-base without having to branch it over to a trial project.
Instead, I do the following:
Create a separate build definition called 'Infrastructure'
clone a production definition
Set the trigger on the Infrastructure build definition to manual.
Set the Infrastructure definitions permissions to allow only [Project]\Build group members to have full control of it.
keeps the notification of broken builds away from the bulk of the team).
Create a separate build process template, called 'Infrastructure.xaml'.
Point the Infrastructure build definition at the Infrastructure process template.
Now when I want to iterate on a new build feature for the team:
Check out the build process template I want to update, and lock it.
Copy the build process template I want to update overtop of the Infrastructure.xaml.
Add my build feature to the Infrastructure.xaml file, and check that in.
Use the Infrastructure build definition to test my changes.
Iterate over 3-4 until I get it right.
Complete the feature and have my changes verified by another Infrastructure team member.
Copy Infrastructure.xaml over the build process template I locked in (1) and check it in.
This still results in 'spam' in the TFS source control, but it keeps the build definition iteration out of the eyes of the team. My build process templates are located out of the main source tree (under the Build Process Templates folder, or in the branches themselves under a 'Core/Build' folder where no-one else on the team is typically paying any attention) so that the team is largely unaffected by it.
#d3r3kk: Why not just branch the template and merge changes back when ready instead of creating copies? That way you can preserve source history in a cleaner way as well.
Ideally, there should be a way to have a build process template that is in progress by having it on your local file system and pointing the build definition to it temporarily. Not sure if something like this exists in later versions of VS/TFS. I haven't seen it available via the UI anyway.

Resources