Project management doesn’t seem to like it when they generate reports from Team Foundation Server and see tons of hours remaining for work that should have already be completed. In my organization, it’s not due to lazy developers not completing their tasks, but people tend to forget to zero out the remaining hours in their tasks before closing it. Luckily, there’s a way to fix that.
Open up a command prompt and change directories to %ProgramFiles%\Microsoft Visual Studio 10.0\Common7\IDE. Then run the following command replacing <url> with the url to your team project collection.
witadmin exportwitd /collection:<url> /p:<ProjectName> /n:Task /f:task.xml
You will need to edit the templates of the various work items if you want this for more than task. Edit task.xml and find the TRANSITIONS section. Find <TRANSITION from="Active" to="Closed">. Then, under the FIELDS section put the following snippet of xml.
<FIELD refname="Microsoft.VSTS.Scheduling.RemainingWork">
<ALLOWEDVALUES expanditems="true">
<LISTITEM value="0" />
</ALLOWEDVALUES>
</FIELD>
Save the file and import it back to TFS.
witadmin importwitd /collection:<url> /p:<ProjectName> /f:task.xml
Now, any time someone attempts to close an active work item, they will receive a warning… and an error if they actually try to save.
This may be a minor annoyance to developers, but it provides more accurate reporting and saves the time required to go back and correct the work items in the future.