Resharper DotCover Analyse for Visual Studio Team Services

Do you use Visual Studio Team Services (VSTS) for Builds and/or Releases? Do you use Resharper DotCover? Do you want to use them together? Then boy do I have an extension for you!

That might be a corny introduction, but it is exactly what I have here.

In my current projects we use Resharpers, or also know as Jet Brains, DotCover to run code coverage on all our code. However to run this in VSTS there is a bit of a process to install DotCover on the server and then write a Batch command to execute it with settings. This isn’t the most complex task, but it does give you a dependency to always install this on a server, and have the written Batch script in source control or in the definitions on VSTS. This can cause issues if you forget to get it installed or you need to update the script for every project.

Therefore I got all that magic of the program and cramed it into a pretty package for VSTS. This tool is not reinventing the wheel, but putting some greese on it to run faster. The Build/Release extension simply gives you all the input parameters the program normally offers and then runs them with the packaged version of DotCover that comes with the extension. See simply.

There is however one extra bit of spirit fingers I added into the extension. When researching and running my own tests, I found that some times it is helpful to only run the coverage on certain projects, but to do this you need to specify every project path in the command. Now I don’t know about you, but that sounds boring, so I added an extra field.

Instead of in the Target Arguments passing each project separately and manually, you can pass wildcards in the Project Pattern. If you pass anything in the Project Pattern parameter it will detect you want to use this feature. It then uses the Target Working Directory as the base to recursively search for projects.

For Example: Project Pattern = “*Test.dll” and Target Working Directory = “/Source”

This will search for all DLL that end with ‘Test’ in the ‘Source’ directory and then prepend it to any other arguments in the Target Arguments.

For Example: “/Source/MockTest.dll;/Source/UnitTest.dll”

You can download the extension from the VSTS Marketplace
Here are is a helpful link for Resharper DotCover Analyse – JetBrains
Then this is the GitHub Repository for any issues or some advancements you would like – Pure Random Code GitHub

Update 20-07-2018

There was a recent issue raise on the GitHub Repository that addressed a problem I have also seen before. When running the DotCover from Visual Studio Team Services an error appears as below:

Failed to verify x64 COM object registration: Empty path to COM object.

From the issue raise, the user had linked to a Community Article about “DotCover console runner fails when running as VSTS task“, which in the comments they discussed how to fix this.

To correct it we simply add the following command to the request, that specifies what profiled process bitness to use as they say.


Therefore the task has now been updated with this field and feature to accomadate this issue and fix. It has been run and tested by myself plus the user that raised the issue, so please enjoy.

How to Self Authenticate in .NET MVC C#

When you build your website application and you have a sign in section, most people use their own cookies to store the user information to validate the users is logged in, but with .NET MVC you can use the built in authentication to sign in, sign out and control there role.

This feature enables you to neatly store the users information to validate them without all the fuss of using your own cookies, but better yet it is also encrypted for you as well. With the MVC concept you can then put the Authorized Attribute on your View Action Results to block them going to that page without being logged in. You can read more about this attribute and how to use the Authorization feature on Microsoft website here. This is all amazing and great, but this is built in with MVC so a bit restricted to use their set up using the details and roles of the current PC.

However after a bit of hunting and testing I found out how to use their authentication, but at your own will. After you have done your post back with the information of the user and you have done your checks to make sure they are an existing user etc. You can then sign them in with this piece of code below:

using System.Web.Security;

FormsAuthentication.SetAuthCookie(userName, false);

userName is of course the username of the person signing in. That is all you need to do with no hassle. You can then retrieve is the user is valid in your view and other pages via this:


This will return a boolean if the user is signed in.

You can then also sign them out with the below:


The problem I then also found what how do I then see what role the user is as I am not using the built in Authentication. I hunted again and found the way…

userName = the user name
userRole = the role you would like to assign

FormsAuthentication.SetAuthCookie(userName, false);

            FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(1, userName, DateTime.Now, DateTime.Now.AddDays(1), false, userRole, "/");

            HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName,


This creates a FormsAuthenticationTicketwhich is basically a collection of information of the user. This is then store in the same place as where your standard encrypted username would be stored. This can thenhold the string of what the users role is, plus any other information you would like to store.

To get the role out gets a bit longer though as you need to check the cookie and then un-encrypt it like below:

String userRole = "";
            var httpCookie = Request.Cookies[FormsAuthentication.FormsCookieName];
            if (httpCookie != null)
                FormsAuthenticationTicket formsAuthenticationTicket = FormsAuthentication.Decrypt(httpCookie.Value);
                if (formsAuthenticationTicket != null)
                    userRole = formsAuthenticationTicket.UserData;

fter checking the cookie exists you can then get the FormsAuthenticationTicketby Decrypting the cookie value. This will then put it in to the class object that you can get the data.