Running Code Analysis (FxCop > 10) on build agent without installing Visual Studio

前端 未结 5 1940
生来不讨喜
生来不讨喜 2020-11-29 17:02

After FxCop 10 Microsoft stopped shipping a separate installer for FxCop. Officially one can currently only run code analysis (FxCop 12.0 / 14.0 / 15.0) after installing Vis

5条回答
  •  被撕碎了的回忆
    2020-11-29 17:20

    Using FxCop for SonarQube analysis without installing Visual Studio

    If you have any FxCop rules enabled in your SonarQube quality profile, SonarQube requires FxCop 14.0.

    These steps are largely based on the outstanding answer by @BatteryBackupUnit:

    1. Install Microsoft Build Tools 2015 on the build machine.

    2. Install Microsoft Visual C++ 2015 Redistributable Update 3, both x86 and x64, on the build machine.

    3. Import the following registry file (update drive letter if not C:) on the build machine:

    
    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\\"
    
    1. Copy all of %programfiles(x86)%\Microsoft Visual Studio 12.0\Team Tools\Static Analysis Tools (not just the FxCop subdirectory) to the same place on the build machine.

    2. Copy %programfiles(x86)%\MSBuild\Microsoft\VisualStudio\v14.0\CodeAnalysis to the same place on the build machine.

    3. From the Global Assembly Cache (C:\Windows\Microsoft.NET\assembly\GAC_MSIL_NameOfTheAssembly_) of a computer where VS2015 is installed, copy Microsoft.VisualStudio.CodeAnalysis.dll and Microsoft.VisualStudio.CodeAnalysis.Sdk.dll (Make sure the DLLs are version 14.0!). Either copy to C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\CodeAnalysis on the build machine or install into the build machine's GAC.

    If you see Phx.FatalError after all this - there's one last ritual... Copy vs_profiler_x64_enu.exe from Program Files (x86)\Microsoft Visual Studio 14.0\Team Tools\Performance Tools\Setups and install it on the build machine.

    Deviations from @BatteryBackupUnit's instructions:

    1. The entire Static Analysis Tools directory is needed, not just the FxCop subdirectory.
    2. Instead of nesting a Msbuild subfolder under FxCop, you need to place it in the original location.
    3. Copying msdia120.dll and amd64\msdia140.dll files into the FxCop directory seems unnecessary so long as the Visual C++ 2015 Redistributable is installed.
    4. No FxCop-related modifications to the project file (*.csproj).
    5. No Custom.CodeAnalysis.targets file.

提交回复
热议问题