Intro

Somewhere between .NET 4.0 release and .NET 4.6.2 (latest of this time) Microsoft decided to go open-source with .NET ecosystem and separate the framework from the build tools and from IDE.

In the same interval, the SonarQube (SQ) team reworked and extended the core plugin(s) for analysing .NET projects twice such that, at this time, SQ is able to understand almost all types of files from .NET projects (except .aspx, .ascx ones).

This tutorial aims at setting up a Windows 7 machine for doing SQ analysis on .NET 4.x projects.

Prerequisites

You should already have a real or virtual machine with licensed Windows 7 64-bit on it and with all windows updates installed. The system partition (usually C:) should have at least 70Gb.

The following software kits must be downloaded:

  1. Windows Management Framework 5.0 - for latest version of Powershell
  2. latest Java JDK 64-bit and JRE 32-bit releases
  3. latest 7-zip release
  4. latest Git version for Windows - if the project(s) are kept in git scm
  5. latest TortoiseHg release - if the project(s) are kept in mercurial scm
  6. latest SlikSVN release - if the project(s) are kept in svn scm
  7. Cygwin 64-bit
  8. latest NodeJS LTS release - for the web projects that use bower, grunt, gulp
  9. .NET framework 4.0
  10. .NET framework 4.5
  11. .NET framework 4.5.1
  12. .NET framework 4.5.2
  13. .NET framework 4.6
  14. .NET framework 4.6.1
  15. .NET framework 4.6.2
  16. .NET framework 4.5.1 developer pack
  17. .NET framework 4.5.2 developer pack
  18. .NET framework 4.6 targeting pack
  19. .NET framework 4.6.1 targeting pack
  20. .NET framework 4.6.2 developer pack
  21. Windows SDK fr Windows 7 and .NET framework 4.0
  22. Windows SDK for Windows 8 - web installer
  23. Windows SDK for Windows 8.1 - web installer
  24. Microsoft Visual Studio 2010 Shell (Isolated) Redistributable Package
  25. Microsoft Visual Studio 2010 Shell (Integrated) Redistributable Package
  26. Microsoft Visual Studio 2012 Shell (Isolated) Redistributable Package
  27. Microsoft Visual Studio 2012 Shell (Integrated) Redistributable Package
  28. Microsoft Visual Studio 2013 Shell (Isolated) Redistributable Package
  29. Microsoft Visual Studio 2013 Shell (Integrated) Redistributable Package
  30. Microsoft Visual Studio 2015 Shell (Isolated) Redistributable Package
  31. Microsoft Visual Studio 2015 Shell (Integrated) Redistributable Package
  32. Microsoft Build Tools 2013 - this is MSBuild 12.0
  33. Microsoft Build Tools 2015 - this is MSBuild 14.0
  34. Agents for Microsoft Visual Studio 2013
  35. Agents for Microsoft Visual Studio 2013 Update 5
  36. Agents for Microsoft Visual Studio 2015
  37. Agents for Microsoft Visual Studio 2015 Update 3
  38. StyleCop 4.7.55
  39. TypeScript for Visual Studio 2013
  40. TypeScript for Visual Studio 2015
  41. Visual Studio 2015 Professional Edition ISO
  42. jsMSIx.exe - for extracting FxCop from Visual Studio 2015 image

Installation

  • Install #1 to #3 (WMF 5.0, Java JDK and JRE, 7-zip).
  • Choose and install the needed SCM client(s) from #4 to #6 (SlikSVN, TortoiseHg, Git). You can also install all of them since they do not conflict with one another.
  • Install #7 (cygwin) if you need bash support.
  • Install #8 (NodeJS) if projects use grunt, gulp, bower or other NodeJS modules.
  • Install #9 to #20. If your Windows 7 box is up to date then you already have the .NET frameworks installed (you will receive a message like .NET Framework 4.x or a later update is already installed on this computer or Same or higher version of .NET Framework 4.x has already been installed on this computer.).
  • Reboot
  • Install #21 (.NET 4.0 SDK). The default setup executable of .NET 4.0 SDK has issues with the VC++ runtimes installed on the machine so you must extract the files from the .iso (\GRMSDKX_EN_DVD.iso) using 7-zip and run the extract_folder/Setup/SDKSetup.exe

Extract iso

  • Install #22 and #23 (Windows 8 and 8.1 SDK).

  • Install #24 to #33 (Visual Studio 2010, 2012, 2013 and 2015 isolated and integrated shells, MSbuild tools).

  • Install #33 to #37 (Test Agents) by extracting the files from .iso image using 7-zip and running extract_folder/TestAgent/vstf_testagent.exe.

  • Extract and install FxCop from Visual Studio 2015 image (based on this StackOverflow post):

    1. Extract files from Visual Studio .iso file using 7-zip

    2. Go to extract_folder/packages/communitycore/Setup/

    3. Extract #42 (jsMSIx.exe) to extract_folder/packages/communitycore/Setup/ from the previous step

    4. Start jsMSIx.exe and select the vs_communitycore.msi in its GUI. Click “Unpack Installer info” button. Extract iso

    5. The jsMSIx.exe extracts all the files in the .msi in extract_folder/packages/communitycore/Setup/, with their complete path (as they would be placed on the target machine if the .msi would be run).

    6. Copy extract_folder/packages/communitycore/Setup/Program Files/Microsoft Visual Studio 14.0/Team Tools/Static Analysis Tools folder to C:/Program Files/Microsoft Visual Studio 14.0/Team Tools/Static Analysis Tools

    7. Copy extract_folder/packages/communitycore/Setup/Program Files/MSBuild/Microsoft\VisualStudio/v14.0/CodeAnalysis folder to C:/Program Files/MSBuild/Microsoft/VisualStudio/v14.0/CodeAnalysis

    8. Copy Microsoft.VisualStudio.CodeAnalysis.dll, Microsoft.VisualStudio.CodeAnalysis.Sdk.dll, StanCore.dll, MetricsPackage.dll from extract_folder/packages/communitycore/Setup\Windows/Microsoft.NET/Framework/URTInstallPath_GAC to C:/Program Files/MSBuild/Microsoft/VisualStudio/v14.0/CodeAnalysis

    9. Import the following registry key

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\WDExpress\14.0\Setup\EDev]
"StanDir"="C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Team Tools\\Static Analysis Tools\\"
"FxCopDir"="C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Team Tools\\Static Analysis Tools\\FxCop\\" 
  • Now you can do SonarQube analysis on .NET 4.0 projects

Final thoughts

I hope Microsoft will reconsider bundling FxCop in Visual Studio and will provide a stand-alone installer, as it did for FxCop v10). Especially since it looks like the code analysis feature is avaliable in all Visual Studio editions.

If you also need to support .NET 3.5 projects then install the framework and its SDK first and Visual Studio 2008 isolated and integrated shell redist., before any Windows 7 update. Otherwise either the SDK will not be installed properly or the MSBuild 14 will get broken.

Enjoy!

Comments

Want to leave a comment? Visit this article's issue page on GitHub (you'll need a GitHub account)