Tuesday, March 12, 2013

CodeMetrics and VS 2012 workaround

As it is for now, running metrics.exe on a machine which doesn't have VS 2010 gives you an error:

Could not locate C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\metrics.exe. Please download Visual Studio Code Metrics PowerTool 10.0 at http://www.microsoft.com/downloads/en/details.aspx?FamilyID=edd1dfb0-b9fe-4e90-b6a6-5ed6f6f6e615

Downloading and installing as it says - doesn't really help, it gives yet another error about missing dll or one of its dependencies.

So, to be able to run code metrics tool on a machine without VS 2010 installed, do the following:

1. Create folder C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools
2. Copy over the whole Static Analysis Tools folder there from the machine with VS2010.
3. Copy Microsoft.VisualC.dll version 10.0.0.0 to the FxCop subfolder of Static Analysis Tools folder.

This made the trick.

UPDATE: It's finally there! See CodeMetrics for VisualStudio 2012.

Saturday, March 2, 2013

Best tools ever: LINQPad

I thought to make serie of posts about tools I use daily, and can't imagine life without.
And I start with my very favourite - LINQPad.

So often there is a code snippet we just want to try, and starting all the hussle with opening Visual Studio, creating project, etc etc... uff, it is just too much. Life should be easy - write & run!

And that is exactly what LINQPad allowes me to do.

So start LINQPad - and you get a window to write your code:

 
Select a C# statement, and - write your code. In this particular example I query for build definitions, and if I press Run, it will show me the result in nice format:


Of course, there are dlls I need to reference. To add references required by your code - right click on the code field and choose Query Properties.


And look - there is even NuGet there.

 Best news ever - you can get it for free. If you would like to have code autocompletion - it will cost you some, otherwise - totally free of charge.

I have to add that LINQPad can do much more than what I mostly use it for, so - try it and I am 100% sure you will love it.

Official site, download and examples here: http://www.linqpad.net/