Fixing JSON serialization issues when using a VSTS / TFS Service Hook

Today I was working on an integration project when I discovered some unwanted behavior when utilizing a Service Hook when trying to capture a changed work item. I used the following strategy (see this excellent blog post by René van Osnabrugge) to create JSON classes for a generated request. While debugging my solution I figured out that not all properties had values. What could be the issue?

Setting up the scenario

Using the previously mentioned strategy I have created some C# classes for the JSON from the Service Hook. I use these classes in my method to capture the Service Hook. Specifying the “TFSHook.RootObject” automatically transforms the JSON into the classes.

Method Definition

Finding the issue…

I expected all the classes to be automatically filled with the values from the received JSON stream. Unfortunately, some of the classes where empty.

Empty Properties

First thing I went to validate was whether the JSON actually contained the values. Now once the request has been transformed it is not very easy to get the original JSON. Luckily the Service Hooks page has an excellent history view, in there you can find all you need.

Service Hook Request Details

With the extra set of eyes from Mark Dekker we quickly discovered that the some of the properties HAVE a “.” in their names, while inspecting the generated JSON classes did NOT HAVE a “.” in their names.

The solution

Call it a bug or a feature, the solution is all that matters for now. In the generated classes we can easily decorate the properties with an JSON attribute that will allow us to specify the property name to look for in the JSON stream.

Code Snippets

Voila! Running this will provide you with objects containing the actual values.

Bonus Material: Increasing the debugging experience

When debugging your Service Hook, changing some code and then debugging again may give an unexpected behavior, your previous breakpoint may not be hit. My experience is that when something goes wrong in your code, or a timeout happens, the Service Hook is set to “Enabled (restricted)”.

Enabled Restricted Service Hook

This can be easily fixed by choosing “Enable” from the context menu.

Enable a Restricted Service Hook

Be sure to have the Service Hooks page around when developing a Service Hook. This post proves how useful it can be!

Broken XAML Builds with error TF215097

Today at a customer I received notifications of failing builds. Before the weekend all was running OK and this morning builds started to fail. After first inspections it turned out that only my XAML based builds were failing. V-Next type builds worked OK.

Below is an example of the failure:

TFS Build Failure

The error in plain text:
TF215097: An error occurred while initializing a build for build definition \xxxxxxxxxxxxx\xxxxxxxxxxx-DEV: 
Exception Message: A procedure imported by 'Microsoft.VisualBasic.Activities.Compiler.dll' could not be loaded. (type FileLoadException)
Exception Stack Trace:    at Microsoft.VisualBasic.Activities.VisualBasicHelper.CompileT
   at Microsoft.VisualBasic.Activities.VisualBasicHelper.CompileT
   at Microsoft.VisualBasic.Activities.VisualBasicHelper.CompileT
   at Microsoft.VisualBasic.Activities.VisualBasicValue1.CacheMetadata(CodeActivityMetadata metadata)
   at System.Activities.CodeActivity1.OnInternalCacheMetadataExceptResult(Boolean createEmptyBindings)
   at System.Activities.Activity1.OnInternalCacheMetadata(Boolean createEmptyBindings)
   at System.Activities.Activity.InternalCacheMetadata(Boolean createEmptyBindings, IList1& validationErrors)
   at System.Activities.ActivityUtilities.ProcessActivity(ChildActivity childActivity, ChildActivity& nextActivity, Stack1& activitiesRemaining, ActivityCallStack parentChain, IList1& validationErrors, ProcessActivityTreeOptions options, ProcessActivityCallback callback)
   at System.Activities.ActivityUtilities.ProcessActivityTreeCore(ChildActivity currentActivity, ActivityCallStack parentChain, ProcessActivityTreeOptions options, ProcessActivityCallback callback, IList1& validationErrors)
   at System.Activities.ActivityUtilities.CacheRootMetadata(Activity activity, LocationReferenceEnvironment hostEnvironment, ProcessActivityTreeOptions options, ProcessActivityCallback callback, IList1& validationErrors)
   at System.Activities.Validation.ActivityValidationServices.InternalActivityValidationServices.InternalValidate()
   at Microsoft.TeamFoundation.Build.Workflow.WorkflowHelpers.ValidateWorkflow(Activity activity, ValidationSettings validationSettings)
   at Microsoft.TeamFoundation.Build.Hosting.BuildProcessCache.LoadFromXaml(String workflowXaml, TextExpressionImports textExpressionImports)
   at Microsoft.TeamFoundation.Build.Hosting.BuildControllerWorkflowManager.PrepareRequestForBuild(WorkflowManagerActivity activity, IBuildDetail build, WorkflowRequest request, IDictionary`2 dataContext)
   at Microsoft.TeamFoundation.Build.Hosting.BuildWorkflowManager.TryStartWorkflow(WorkflowRequest request, WorkflowManagerActivity activity, BuildWorkflowInstance& workflowInstance, Exception& error, Boolean& syncLockTaken)
First explorations did not immediately gave me a clue but after some digging I came up with the following link: https://support.microsoft.com/en-us/kb/3118750

Reviewing the post verified that this was compliant with my scenario.

I followed resolution 1, by first installing the update to 4.6.1. This however did not fix my issues. Thus I rolled this update back. I then continued uninstalling KB3097997 and KB3098779. The latter required a reboot.

After rebooting I was able to queue my XAML Builds again successfully.

Happy Building!

Mirror, mirror on the wall – A personal retrospective exercise

Great post!

The Road to ALM

During the last year I did quite some Scrum coaching for different teams in different organizations. What I found is that a lot of Scrum teams follow the ceremonies and the rules of Scrum. That is a good thing. What I also found out is that many Scrum teams do not get the most out of their retrospectives. The talk about the process, mention what goes right and mentions what goes wrong, but they do not really follow up the points mentioned. Rookie Scrum teams get some value out of their retrospectives. Most of the times because it is easy to find some points of improvement. The build does not work, more unit testing is needed, we should sit together. But the more mature a Scrum team becomes the harder it gets to find improvements.

A scrum team (just like any other team) goes through 4 different stages of maturity.

View original post 426 more words

Tweaking the TFS Web Access Client

Recently Microsoft released a great usability tweak to the Web Access Client on Visual Studio Online. It allows users to use the rich text editor in full screen mode. This allows users to utilize the most out of their big screens and allows users to have a better editing and reading experience for large text fields, especially when combining images and text. More of these new features can be read here: Work item Improvements

While these features are to be expected to be in the next on premise TFS release, you may like to have similar functionality in your on-premise TFS right now!

Let me start with a disclaimer: The customization’s in this post are not supported by Microsoft. These changes can break any updates and will be undone by any update installations to your TFS environment. 

For all of you accepting this disclaimer the following adjustments will allow you to use the most of your available screen size.

When you currently open a work item from the task board (or most other locations) you will see the following behavior. As the red arrows indicate, there is allot of space available at the edges and the rich text fields do not utilize the space available.

Default Work Item Experience

The steps below guide you to change the default behavior.

1. Download the FullDialog.css from my DropBox. FullDialog.css or FullDialog.zip

The CSS changes to UI Dialog to be positioned 45px from the top, and to utilize 98% of the available width. For the height it will use 85% of the View Port. Caution this may / will not work on ‘old’ browsers.

Work Item Experience CSS

2. Add the FullDialog.css file to the following directory on your TFS server.

%ProgramFiles%\Microsoft Team Foundation Server 12.0\Application Tier\Web Services\_static\tfs\12\App_Themes\Default\

3. Open the Main.Master file

%ProgramFiles%\Microsoft Team Foundation Server 12.0\Application Tier\Web Services\_views\Shared\Main.Master

4. Add the following line to the indicated location

<link href=”<%:Url.Themed(“FullDialog.css”) %>” type=”text/css” rel=”stylesheet” />

Changes to Main.Master Page

The marked line indicates the location to add the custom CSS file.

5. Execute an IISReset from the commandline. (Mind your step when doing this in a production environment!)

6. Test results! You’re workitem experience is now almost fullscreen and you’re rich text fields will utilize much more space.

Full Screen Work Item Experience

Full Screen Work Item Experience

Additional options, TFS has two UI settings modes available; Default and High contrast. If you do not wish to adjust the Default behavior for all your users you might want to implement this in the High Contrast profile only. This way you provide your users with a choice. These settings can be reached through your User Profile page.

TFS User Profile UI Settings

New curation on Extending Visual Studio

Recently i have been playing with creating Visual Studio Extensions a bit and found that information was sometimes hard to find or comprehend.

To share the links a have gathered along the way I have created a new curation on Curah! which can be found here: http://curah.microsoft.com/83718/visual-studio-package-extensions

While I am still in the middle of exploring possibilities i will update the curation occasionally.