I need to get the ChangeSetId in tfspreview for our continuous integration. I just need this single number nothing else. I tried all possible MSBuild tasks that I could find, but there is always another smaller issue stopping me.
For MSBuild.ExtensionPack.Tfs.TeamBuild
I get :
Could not load file or assembly 'Microsoft.TeamFoundation.Client, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
and for TfsClient -task
in community-pack (which is generating following exec: tf.exe history . /StopAfter:1 /noprompt /format:detailed /recursive
) I get:
The specified task executable could not be run. The system cannot find the file specified
My question is;
Is it possible to execute TF.exe
on tfspreview server?
or can I get the assembly Microsoft.TeamFoundation.Client
on the build server to execute one of these two tasks?
Alright, I am here to tell you that this IS possible without writing your own custom task, using the API, etc... there are a number of articles out here on StackOverflow but the ones with solutions do not appear to work for TFS 2010. I just spent an entire day banging my head against the wall :D
You need to install the MSBuild Community Tasks. Make sure you get the latest version from here: https://github.com/loresoft/msbuildtasks. The latest appears to have been updated and rebuilt against the TFS 2010 assemblies.
You are going to use the MSBuild.Community.Tasks.Tfs.TfsClient task. The reason you are getting that error about not being able to run the executable is because this is an MSBuild ToolTask and you need to pass in the path to the executable as a property (ToolPath) to the task.
The TfsClient task is just a wrapper to tf.exe and the task is missing a lot of possible features for handling the switches in an MSbuild-y way. (and the documentation for this task is nonexistant - i had to look at the code) Luckily I figured out that you can enter all of the command line switches as part of the command itself.
So your final call will look something like this...
And after 22 miserable failed builds or builds with no data I finally got... TFS ChangeSetNumber: 41
YAHOO!
Got the command from Martin Woodward: http://www.woodwardweb.com/vsts/determining_the.html MAKE SURE YOU USE THE /DETAILED SWITCH OR IT WONT RETURN THE CHANGESET. I had to look at the code for the task and figure out how it was parsing the output from tf.exe to figure this out.
Code for TfsClient is here for reference: https://github.com/loresoft/msbuildtasks/blob/master/Source/MSBuild.Community.Tasks/Tfs/TfsClient.cs
What exactly does the MSBUILD workflow look like? Are you passing this parameter into MSBUILD or is some custom component grabbing this information while MSBUILD is running?
I've come across the class InformationNodeConverters, which has the method GetAssociatedChangesets that takes in an IBuildDetail and returns a List of IChangesetSummary. This would also require that your changesets already be associated before you get to the MSBUILD task. I'll need to check against my TFSPreview instance tonight to see if I can edit the build template, but I would suspect that you should be able to use something like this.
Here's the line of code that worked for me.. after several hours and couple of tries. the difference is that I created an output TaskParameter element within the
Where:
ToolPath ="C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE" - depends if you're on 32 or 64 bit.
$/WorkspacePath name of the path on my workspace, you can view this using tf workspace command
But thanks to this thread