TFS Changeset history using QueryHistory after branch rename - tfs

I'm using the VersionControlServer.QueryHistory method to retrieve a list of files that have changed during a timespan that ranges from 5/1/2009 to 10/1/2009. My results unexpectedly only included items that had changed after 9/1/2009. I then realized that the path that I was using, $/Project/Reports/Main, didn't exist until 9/1/2009. Before 9/1/2009, there had been another node named $/Project/Main/Reports, which was renamed to $/Project/Reports/Main.
When I query from Source Control Explorer I can see the entire history (5/1/2009 - 10/1/2009) that I expect to see. However, I can't get the same results via the API. I've tried to specify the branch that no longer exists because it was renamed, but not surprisingly I get zero results. Any ideas?

I believe you need to pass the slotMode parameter as false; that instructs TFS that you want the history for the item that currently occupies that slot, even if it did not always do so (passing it as true gives you the history of that slot).
See the docs for more information.

Related

Any documentation for the XML format of TF.EXE's vc status command?

I am writing a script which will act on modified files in my TFVC (Microsoft Team Foundation Version Control) workspace. I'm invoking tf.exe vc status /format:xml to get the list of changes, but I need to exclude deletes. Is the XML format it returns documented? I know I want to filter on the chg attribute of the PendingChange elements, and I could discover the value by deleting a file and seeing what it returns, but I suspect there may be other values that I should check for as well. It would be much nicer to work off a documented canonical list rather than fixing the script each time it fails on a new value or combination I hadn't seen before. Does the documentation or a schema definition exist? (Neither of the two search engines I use led me to any.)
It seems there is no such documentation available yet. The pending change types using mostly are as below:
I've tested the chg attribute of the PendingChange element in the XML file for the pending change type above, you may reference it:
PendingChange chg="Encoding Branch"
PendingChange chg="Undelete"
PendingChange chg="Rename"
PendingChange chg="Edit"
PendingChange chg="Add Edit Encoding"
PendingChange chg="Edit Rollback"
PendingChange chg="Delete"
PendingChange chg="Edit Encoding"
I found the pending change types come from the enumeration Microsoft.TeamFoundation.VersionControl.Client.ChangeType which is documented in the TFVC client API documentation here: https://learn.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2013/bb170193%28v%3dvs.120%29. Although it's not documentation of the XML format, it is the canonical list of the possible values.
As a side note, I ended up not being able to use the XML output for my script since it does not include new files (unless they have been specifically added, which in my scenario they are not) which I needed for my script. (Since I didn't have time to code to the TFVC client library, I parsed the output from tf vc status /format:brief.)

Newly created build process parameters not showing up

When I add a new parameter in the Process Parameter Metadata Editor, checkin my changes, and go back to edit the definition or queue a build from it, the parameter is not showing. Here is the parameter in the editor:
Other custom parameters I added in the past show up fine. For example, this one shows up fine:
So..I would expect my new parameter to show up the same way this one works.
I tried closing and re-opening VS2013 (I have update 4) and changing to another build controller, but get same behavior. How do I fix this?
A parameter must be defined at the Build Arguments level (the place you found the Build Parameters Metadata).
Afterwards, the Metadata defines how it shows up, which editors it uses, and what description should be shown on it.
That's about the metadata, but you need to add your parameter in the Arguments tab.
You will find it in the XAML Workflow editor at the bottom three buttons/tabs: Variables, Arguments and Imports.

How do I change the Build number format parameter while queuing a build

I am using Visual Studio Online for Source Control and Build processes. I created a new build definition using the TfvcContinuousDeploymentTemplate.12.xaml. When Queuing a new build from within VS I have the chance to change some parameters, but I can't change the Build number format. What determines what shows up on that parameter list and how can I make sure the Build number format appears there?
My suggestion is to investigate modifying the build template to:
1) Take a custom input value, which I believe you can change on each invocation of the build; and
2) Finding the appropriate step to interrogate the existing Build Number and modify it based on this input.
This should get you started:
http://msdn.microsoft.com/en-us/library/dd647551.aspx
Alternatively, you could remove the Build Number Activity in its entirety and substitute your own – but I don’t think these measures are warranted in this case. This would get you started down that trail:
http://blogs.msdn.com/b/willbar/archive/2010/01/21/generating-custom-build-number-in-tfs-build-2010.aspx
HTH –
jlo
To show the property you have to edit the template, expand the arguments, search for Metadata and click on the ellipse towards the right of the row. Find the property you want, in my case it is BuildNumberFormat and change the View this parameter when: Always show the parameter

How does TFS's convertworkspaceitem work?

I'm trying to follow the instructions for deploying a database via TFS build listed here:
http://www.mytechfinds.com/articles/software-testing/6-test-automation/64-db-deployment-tfs
The instructions include notes about how to configure a ConvertWorkspaceItem element. I've followed the directions, but TFS remains unhappy with my setting for 'Result' and 'Workspace'. For now, I simply entered the text from the directions ('dbproj' and 'Workspace', respectively). TFS complains about my values:
Compiler error(s) encountered processing expression "dbproj". 'dbproj' is not declared. It may be inaccessible due to its production level.
I'm trying to find basic tutorial information on the ConvertWorkspaceItem element, but other than the MSDN reference page there isn't a lot of info. Does anyone know much about configuring this element?
You need to specify valid variable names for both of these properties. there should already be a variable declared in the workflow called workspace, You will need to declare a variable of type string that you wish to receive the result of this activity and specify it's name as the Result property. It looks like in your linked article the author must have already created a variable called dbproj. At the bottom of the workflow designer is a variables tab where you can define your own variables.

Get labels applied to a particular version of an item in TFS source control

I'm trying to get a list of labels that apply to a particular version of a particular file in TFS Source Control. So far, I've gotten a set of labels that apply to any version of a particular file. Does anyone have any experience getting labels for a particular item?
For example, I have $/Project/Folder/Item.cs, which was modified in changesets 301, 401, and 601. Labels Build1 - Build 99 exist for the project. Build1 - Build10 were applied before changeset 301 (i.e. before Item.cs was created). Build96 - Build99 were applied to the v601 of Item.cs. If I run
vcServer.QueryLabels(null, "$/Project", null, false, "$/Project/Folder/Item.cs", new ChangesetVersionSpec(6))
I get Build11 - Build99 as results. I haven't figured out how to get a query to return fewer than this many labels. Ideally, the query I run will return 4 labels (Build96 - Build 99).
The context of this question is a TFS Project, with CCNET for a build server. I'm trying to relate work items to builds, starting with a work item number.
Any tips? Or examples of QueryLabels? Or better docs for QueryLabels than the MSDN docs?
This is possible, see here: http://social.msdn.microsoft.com/Forums/en-US/tfsversioncontrol/thread/9f41f37e-4fda-4b56-91a3-f2b7e0c0e22d
Basically, once you get back the list of labels, you have to look through each label and see what changeset of the item you're interested in it applies to. Be sure to pass in the "includeItems = false" flag to QueryLabels, otherwise you'll have to look through every item on the label.
What you are wanting to do should definitely be possible using the API. The answer I gave to the other question was about seeing the labels inline with history in the UI.
For more information about doing what I think you are wanting to do, then take a look at:
Buck Hodges: Finding the changes between two labels in TFS version control
and also
Manish Agarwal: What is GenCheckinNotesUpdateWorkitem task?
Hope that helps.
Martin.
It looks like it's not possible with the current TFS version, but may be with the next.

Resources