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.
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:
- Windows Management Framework 5.0 - for latest version of Powershell
- latest Java JDK 64-bit and JRE 32-bit releases
- latest 7-zip release
- latest Git version for Windows - if the project(s) are kept in git scm
- latest TortoiseHg release - if the project(s) are kept in mercurial scm
- latest SlikSVN release - if the project(s) are kept in svn scm
- Cygwin 64-bit
- latest NodeJS LTS release - for the web projects that use bower, grunt, gulp
- .NET framework 4.0
- .NET framework 4.5
- .NET framework 4.5.1
- .NET framework 4.5.2
- .NET framework 4.6
- .NET framework 4.6.1
- .NET framework 4.6.2
- .NET framework 4.5.1 developer pack
- .NET framework 4.5.2 developer pack
- .NET framework 4.6 targeting pack
- .NET framework 4.6.1 targeting pack
- .NET framework 4.6.2 developer pack
- Windows SDK fr Windows 7 and .NET framework 4.0
- Windows SDK for Windows 8 - web installer
- Windows SDK for Windows 8.1 - web installer
- Microsoft Visual Studio 2010 Shell (Isolated) Redistributable Package
- Microsoft Visual Studio 2010 Shell (Integrated) Redistributable Package
- Microsoft Visual Studio 2012 Shell (Isolated) Redistributable Package
- Microsoft Visual Studio 2012 Shell (Integrated) Redistributable Package
- Microsoft Visual Studio 2013 Shell (Isolated) Redistributable Package
- Microsoft Visual Studio 2013 Shell (Integrated) Redistributable Package
- Microsoft Visual Studio 2015 Shell (Isolated) Redistributable Package
- Microsoft Visual Studio 2015 Shell (Integrated) Redistributable Package
- Microsoft Build Tools 2013 - this is MSBuild 12.0
- Microsoft Build Tools 2015 - this is MSBuild 14.0
- Agents for Microsoft Visual Studio 2013
- Agents for Microsoft Visual Studio 2013 Update 5
- Agents for Microsoft Visual Studio 2015
- Agents for Microsoft Visual Studio 2015 Update 3
- StyleCop 4.7.55
- TypeScript for Visual Studio 2013
- TypeScript for Visual Studio 2015
- Visual Studio 2015 Professional Edition ISO
- jsMSIx.exe - for extracting FxCop from Visual Studio 2015 image
- 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.).
- 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
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):
Extract files from Visual Studio .iso file using 7-zip
Go to extract_folder/packages/communitycore/Setup/
Extract #42 (jsMSIx.exe) to extract_folder/packages/communitycore/Setup/ from the previous step
Start jsMSIx.exe and select the vs_communitycore.msi in its GUI. Click “Unpack Installer info” button.
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).
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
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
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
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
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.