build latest sources with a changeset in tfs - tfs

I want to get the changeset of last good build of a given build definition and then build for that changeset. Is there any way to achieve this by modifying the defaultTemplate? Maybe I can use an In Argument to pass the build definition name to the build process template.
Any help/direction/insight is appreciated. Thanks. :)

Not sure what you mean by "Latest Sources plus a Changeset", Latest Sources by definition includes all changesets.

In the default template there's an argument "GetVersion" under advanced you can specify a changeset to build.
According to the description this just overrides the iBuildDetail.SourceGetVersion.

Related

Build by changeset date

I'm new to the TFS Build and I'm wondering if I can include in my manual build only those change sets which are not later than date such-n-such.
The general task I'm trying to solve is to build a past release which I did a frozen on date, say, March 1st and omit a recent changes. No branching I do with my project.
Maybe there is a better way to do that?
Thanks.
You can do it when you queue the build.
There is no changeset date concept in TFS expect the creation date of changesets on the same day. Usually we queue a build from a specific changeset in TFS.
You can achieve it by specify the changeset info in Source Version of queue build dialog such as C8 which will build changeset 8. More detail explanation please see below screeshot.
Note: This function is released with TFS2015 update2 for vNext build. To use it, you have to upgrade to Update2 or above.
You could also build a label, how to create take a look at: Use labels to take a snapshot of your files

Using the same TFS build definition for multiple solutions

Our TFS 2013 admins have given us one build definition to build our solution and run all unit tests and they are not willing to create any more build definitions. We are following feature branch strategy and would like to use this build definition for our gated builds. I am trying to find how to use this one build definition with multiple branches.
I know, I can add all branches to Source settings and build them whenever a check-in is made. But I want to find out, if there is any way to add branches to Source settings, but only compile the solution that has been checked in. For example if we add 5 solutions to the Source settings, we want to compile only the solution that has changed rather than all 5 solutions.
You will need to setup an incremental build that only builds the solutions that have changed.
Ideally you will want to setup a build for every branch. You would still use the one build template given to you, but you would define the work-spaces and behavior differently for each branch depending on your needs. However if you do not have that option you can still implement what you are trying to do.
For example if you only want to build the solution that has changed you will set up your build to be an incremental build like the following:
In the "Process" tab update the "Items to build" section to any *.sln or *.*proj
In the "Workspace" section, select only the source control paths of each branch if setting up a build for every branch or select the entire source if that is how you have to do it ($/).
Change the build to an incremental build by changing the Build Process Parameters on the "Process" tab - CleanWorkspace=None
Tag one of the build agents, so that it is the only one used for these incremental builds. Set the build to only use this tagged agent. It is important that the same build agent or set of agents is used for the builds if incremental builds are to work.

TFS Build specific changeset and deploy it using the changeset number

I have a Build Definition to build a solution on my TFS.
This works well, but it always builds the latest version.
How can I force to build a specific changeset from the past?
How can I use/pass this number to the "MSBuild Arguments" to use it there for deployment?
When you queue up the build from Team Explorer, in the Parameters tab one of the Advanced arguments is get version.
Note: I think you need to specify this in the form C123 where 123 is the changeset number.
The answer to your first question is clearly what #Dylan has stated.
To your second part:
The important argument is GetVersion.
Navigate to activity "Run MSBuild for Project" within your Build Process Template, by default this has a value CommandLineArguments equal to
String.Format("/p:SkipInvalidConfigurations=true {0}", MSBuildArguments)
You can change it to something like
String.Format("/p:SkipInvalidConfigurations=true {0} /p:DeployIisAppPath=/changeset/{1}", MSBuildArguments, GetVersion)
and get where you need to go.
If you use the changeset number, then it will only make sense for CI builds, since they typically build a single changeset.
For any other kind of build, I recommend using the build ID, which is unique, and covers the case of a build that builds multiple changesets.

How to do an Automated build in TFS 2010 by a label

I have my automated builds working but I want to be able to go back to a specifc labeled version and build from that source. The build definition under "Process" has the item "Get Version" but this is for a specific changeset which seems fairly useless. Does anyone have any idea how I would go about doing this?
The Get Version accepts what TFS calls an versionspec which can be either a changeset or a label. To specify a label just prefix it with an L.
LMyLabel
#Dylan Smith: Is right. You can specify in the advanced Get Version parameter the label by: LmyLabel or CmyChangeset in order to queue a specific version. There are other options like date, "W" (Version last fetched to your workspace), or "T" (latest version) as well.
For more information: Building a Specific Version with Team Build 2008
During your build process, label the code (In my case I use the build number as part of the label).
Then when you want to build a specific labeled version, pass the label to the build script, get the code from the library by label, build the code, and deploy.
See http://msdn.microsoft.com/en-us/library/fx7sdeyf.aspx for how to get a labeled version.

How to target specific solutions in a TFS team build definition using WF?

Here is my situation.
I setup a build definition for continuous integration using the new workflow system. Then I targeted this definition to a particular solution. I checked-in my solution many times without a problem and the builds have all passed flawlessly on the server.
This morning, I notice that it has been executed but I did not checked-in the solution. I finally discover that when a colleague checked-in another solution, it executed the definition for the solution I am working on.
I am using the original ProcessTemplate.xaml file. I only want this build definition to be executed when I check-in a particular solution or a set of solution I chose. What do I miss here?
Thanks.
There are two things you need to do,
1. Edit build defination and click on the process tab, change the 'Items to Build' to the solution that you are interested to be build as part of your build.
2. Click on the workspace tab and point it only to the branch or specifically to the folder which logically excludes the solutions that you would like to exlude from this ci build.
Make sure you carry these steps across your build definations.
HTH.
Cheers, Tarun

Resources