How do I control when my custom check-in policy is evaluated? - visual-studio-2010

I've created a custom check-in policy for TFS by writing a class that extends PolicyBase (as per MSDN How To: Create Custom Check-in Policies in Visual Studio Team Foundation). The overridden Evaluate() method is where I've got my logic.
Evaluate() gets called when the user clicks the Check In button in TFS which is great as that is what I want.
However, it also seems like Evaluate() gets called when:
Visual Studio is launched AND
The user navigates to the Pending Changes tab for the first time (or if this is already the active tab when VS is launched) AND
The user has items in the pending changes tab.
How can I check under what scenario Evaluate is called? I would only like Evaluate to be called when the user explicitly clicks the Check In button in TFS.
The actual Evaluate method I'm using is quite complicated but I've simplified it to something that still exhibits the same problem:
public override PolicyFailure[] Evaluate()
{
List<PolicyFailure> policyFailures = new List<PolicyFailure>();
if (_isPolicyEnabled)
{
if (PendingCheckin.PendingChanges.Comment.Contains("*"))
{
string msg = "Star in comment";
MessageBox.Show(msg);
policyFailures.Add(new PolicyFailure(msg, this));
}
}
return policyFailures.ToArray();
}
With the above code, if there is a star in the check-in comment and there are Pending Changes, close Visual Studio, when you re-open it will throw up the MessageBox as soon as you navigate to the Pending Changes tab.
The way the check-in policy is being used in my situation is that I check the user's comment for references to items in another system. If they are not present then I throw up an interactive dialog that shows the user a list of items which can be filtered and selected. These are then inserted into their check-in comment. Is there a way within the Evaluate() to find out under which scenario it is called? I could avoid throwing up the dialog under all calls except those triggered by a Check-In.

Evaluate() shouldn't display UI (as Edward Thomson already
mentioned).
Evaluate() should just create failures if there are any
issues.
This will create a list of failures that the user can then double click on. The double clicking of a failure can then be used (handled by the Activate()) to trigger UI components to be displayed. I haven't tried this yet but it pretty much seems like it will work.
The details are in this MSDN forum post: Prompting user from checkin policy occurs multiple times.

Related

Adding work item id by default in the related work items

Every time when I check-in the code in Visual Studio, I need to provide the product backlog item's work item id (task id) in the pending changes window's Related Work Items section.
If I'm working on a module for a week, on each check-in I need to provide the same work item id (at least 5 to 6 check-in in a day). It seems repeating of work.
Is there any possible way to add the work item id by default in the "Related Work Items" section in the Visual Studio settings?
I'm using Visual Studio 2017 and TFS 2012.
Sorry, it's not able to do this. It will not cached the ID you previous entered.
Instead of entering ID, you could also drag work items here to link work item to check in.
Or you could do it the other way around, open the work item and add a link to your previous changeset.
Get the changeset ID by looking at the History of one of the changed files
Open the relevant work item
Select the Links tab
Click the Add button
Select "Changeset" from the Link type dropdown
Enter the changeset ID (from step 1) into the Changeset field, and click OK
Save the work item
After this the work item will also appear in the changeset's list of associated work items.
No, that`s not possible. You may add all your changes to work item after your work will be done:
You may try to use a custom tool with TFS API like that: How to checkin source code with work item associated using TFS API.

Hide TODO tag in Visual Studio Task List

Our codebase has a bunch of TODO comments that no one will ever fix and that the boss refuses to remove.
I would like to hide the TODO's from the Visual Studio task list and just show my custom MEDO tags.
It appears that Visual studio will not let you remove the TODO tag from the task list. The remove button is grayed out for TODO. (You can remove all the other default tags, just not TODO.)
Does anyone know some kind of hack or something that will allow me to remove them anyway? Maybe editing some config file somewhere?
As you've discovered, Visual Studio won't allow you to modify the TODO token, but you can trick it by using the Priority settings to filter it out.
First, set your MEDO token to "High Priority" as shown here:
Then filter the Task List window to only show high priority items. (The filter button is hard to see on that column - you may need to widen it a bit.)
By default, Visual Studio includes the following tokens: HACK, TODO, UNDONE, NOTE.
All you need to do is to remove the TODO from these list of predefined tokens. (you can create your own tokens as well)
On the Tools menu, choose Options.
Open the Environment folder and then choose Task List and then delete the TODO token.
So now you will continue to have TODO comments in your codebase but they will not show in your task list.

Add TFS2013 check-in policy - checkbox

Hi I am looking to add a checkbox to the TFS check-in page in Visual Studio, that a developer has to tick before being able to do a check-in.
This is to act as a reminder for them, so they read the reminder and tick the box to say they have done it.
Is this possible with custom TFS2013 policies? And are there resources/tutorials which explain how this could be done?
For this I would recommend you use a basic checkin note. They will as to put in a note they they have done whatever you want before they can checkin. This will be a hard stop. Like pero was saying in the comment, a work item is also a good solution and a better plan long term. Then you can just turn on checkin policy and force them to pick an item before checkin. This can be overridden, while checkin notes cannot.

Skip A Dialog In Visual Studio Setup Project

I've created a Visual Studio Setup Project (VS 2010) in which one dialog (4 textboxes) is optional. It depends upon a checkbox selection by user in previous dialog. Is there any way I can skip the optional dialog ?
There are no capabilities in Visual Studio setups to do this. VS setups are going away anyway after VS 2010, so you should choose an MSI-building tool that has this capability.
You could in principle use Orca to manually change the MSI tables, such as the ControlEvent table, but it will be virtually impossible unless you already know how the MSI internals work.
I haven't found out a way to skip a dialog depending upon a control(e.g. checkbox or radiobuttongroup) selection by user in previous dialog;
but you can create a custom dialog(ref link1, ref link2) with all required control(s), and then toggle the visibility of the control(s) with "Show/Hide" Action with proper condition statement(e.g. then checkbox or radio buttongroup selection by user in previous dialog), then you can still make it just like skipping a dialog.
Here is my example:
The previous dialog control selected value(already set to be either "Foo" or "Bar") is passed through "SELTYPE".
When SELTYPE="Foo", I will show controls named "CustomControlFoo" and "RadioButtonGroup", and also hide the control named "BodyText";
When SELTYPE="Bar", I will hide controls named "CustomControlFoo" and "RadioButtonGroup", and also show the control named "BodyText".
For more information, please read this Micorosoft's official reference:
ControlCondition Table
The action that is to be taken on the control. The possible actions are shown in the following table.
Table 2
Value Meaning
Default Set control as the default.
Disable Disable the control.
Enable Enable the control.
Hide Hide the control.
Show Display the control.

Is there a tool for emailing Shelveset's and History items from within Visual Studio Team System?

We are using Team Foundation Server for our source control system in Visual Studio. Although we don't do a lot of pair programming, we do have all of our code changes peer reviewed in a process like this:
write code
shelve the code or check it in (if it's low risk)
send an email to a team member with the shelveset name or changeset number (getting the changeset number requires bringing up the History list for the project).
team member receives email, goes to Visual Studio
if it's a shelveset:
bring up the Pending Changes window
press Unshelve button, to bring up the Unshelve dialog
enter the sender's name in the Owner Name text box, and press Find to list the user's shelvesets
searches for the shelveset to find the correct name (usually by ordering my Shelveset Name), and press Details... button to bring up the details
If it's a changeset:
bring up the Source Control Explorer window, and hit the "History" button to bring up the history list
Locate the correct changeset number, and open the details.
Does anyone know of a tool that would allow us to do one or both of these?:
simply select a changeset or shelveset and hit "Send Email", which would either ask for the recipients and send the email, or bring up Outlook with infomration from the item prepopulated
upon receiving the email, link directly to visual studio and the appropriate changeset/shelveset item.
Have you tried the latest TFS power tools from Microsoft? The "team members" feature could help.
There's a Code Review module in the latest TFS Sidekicks.
Several other add-ons (free & commercial) are surveyed here: http://jb-brown.blogspot.com/2009/01/team-system-code-review-presentation.html
There is a rich event model, most of which is not directly exposed in the UI.
In the UI you can get check in emails, but that is about it. The TFS SDK includes information on working, from the command line, with the full event model.
However I don't know if any events associated with shelve sets are included, you can see the schemas for defined events in the folder "‹TFS Install›\Web Services\Services\v1.0\Transforms" on the TFS server.
There are two options on an event being raised, and your filter matching: (1) send an email (with a transform to create the content), (2) call a web service.

Resources