!! For FxCop 12.0 / VS2013 see this answer !!
Launch FxCop 14.0 without installing Visual Studio 2015
Prerequisites:
- MSBuild 14.0 → Install Microsoft Build Tools 2015
- Visual C ++ Redistributable for Visual Studio 2015 x86 ( x86 version is always required, depending on the assembly. Redist x64 may also be required. If it is missing, the error message may be cryptic, for example,
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.VisualStudio.CodeAnalysis.Interop.dll' or one of its dependencies. The specified module could not be found. ). Instead of installing the entire redist, you can also copy the necessary DLLs separately, but at the moment I do not know which ones are needed. This is quite complicated and takes a long time to figure out which ones are definitely missing.
Depending on what you want to build:
- corresponding Windows SDK, e.g. Windows 10 SDK
- corresponding .net SDK / target (SDK.NET Framework 4.6 is included in the Windows 10 SDK)
Files to add to source control
These are the files that I had to add to the original control: (Please note that this may violate some license agreements)
(source control)\tools\FxCop14 │ ├[Engines] │ │ │ ├IntrospectionAnalysisEngine.dll │ └PhoenixAnalysisEngine.dll ├[Msbuild] │ │ │ ├fxcoptask.dll │ ├Microsoft.CodeAnalysis.Targets │ ├Microsoft.VisualStudio.CodeAnalysis.dll │ └Microsoft.VisualStudio.CodeAnalysis.Sdk.dll ├[Repository] │ │ │ ├[Compatibility] │ │ │ │ │ ├Desktop2.0.xml │ │ ├Desktop2.0SP1.xml │ │ ├Desktop2.0SP2.xml │ │ ├Desktop3.0.xml │ │ ├Desktop3.0SP1.xml │ │ ├Desktop3.0SP2.xml │ │ ├Desktop3.5.xml │ │ └Desktop3.5SP1.xml │ └system32.bin ├[Rules] │ │ │ ├DataflowRules.dll │ ├DesignRules.dll │ ├GlobalizationRules.dll │ ├InteroperabilityRules.dll │ ├MaintainabilityRules.dll │ ├MobilityRules.dll │ ├NamingRules.dll │ ├PerformanceRules.dll │ ├PortabilityRules.dll │ ├ReliabilityRules.dll │ ├SecurityRules.dll │ ├SecurityTransparencyRules.dll │ └UsageRules.dll ├[x64] │ │ │ └msdia140.dll (1349 KB) ├[Xml] │ │ │ ├CodeAnalysisReport.xsl │ ├FxCopReport.xsl │ └VSConsoleOutput.xsl ├Architecture-msil.dll ├CodeAnalysis.dll ├CustomDictionary.xml ├FxCopCmd.exe ├FxCopCmd.exe.config ├FxCopCommon.dll ├FxCopSdk.dll ├Microsoft.Cci.dll ├Microsoft.VisualStudio.CodeAnalysis.Common.dll ├Microsoft.VisualStudio.CodeAnalysis.DataflowModels.dll ├Microsoft.VisualStudio.CodeAnalysis.dll ├Microsoft.VisualStudio.CodeAnalysis.Interop.dll ├Microsoft.VisualStudio.CodeAnalysis.Phoenix.dll ├Microsoft.VisualStudio.CodeAnalysis.Phoenix.xml ├msdia140.dll (1057 KB) ├mssp7en.dll ├mssp7en.lex ├phx.dll └Runtime-vccrt-win-msil.dll
Copy them as follows:
full contents of the FxCop installation folder from
%programfiles(x86)%\Microsoft Visual Studio 14.0\Team Tools\Static Analysis Tools\FxCop
from Visual Studio 2015 C ++ redist or any other place: (also see legal information ) copy msdia140 x86 and x64 to:
msdia140.dll (1057 KiB)
amd64 \ msdia140.dll (1349 KiB)
from the global assembly cache ( C:\Windows\Microsoft.NET\assembly\GAC_MSIL\_NameOfTheAssembly_\ ) of the computer on which VS2015 is installed, copy the following DLLs to: (Make sure the DLLs are version 14.0!)
MSBuild \ Microsoft.VisualStudio.CodeAnalysis.dll
MSBuild \ Microsoft.VisualStudio.CodeAnalysis.Sdk.dll
All files from %programfiles(x86)%\MSBuild\Microsoft\VisualStudio\v14.0\CodeAnalysis to
Msbuild \ fxcoptask.dll
MSBuild \ Microsoft.CodeAnalysis.Targets
In addition, I edited the project's msbuild file (* .csproj) as follows (hint: I am a little deviating from the way I used to do this with VS2013. This is not because FxCop 14 works differently, but because this way I can enable fxcop using the nuget package and use the standard nuget functions to import the .targets file into .csproj):
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets"/> <Import Project="$(ProjectBuildScriptDir)Custom.CodeAnalysis.targets"/>
And here is what our Custom.CodeAnalysis.targets contains:
<?xml version="1.0" encoding="utf-8"?> <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <FxCopDir>..\FxCop14\</FxCopDir> <CodeAnalysisCulture>en-US</CodeAnalysisCulture> <CodeAnalysisRuleSet>$(SolutionDir)FxCop.ruleset</CodeAnalysisRuleSet> <RunCodeAnalysis>true</RunCodeAnalysis> <CodeAnalysisTreatWarningsAsErrors Condition="'$(IsRunningOnTeamCity)' != 'true'">true</CodeAnalysisTreatWarningsAsErrors> </PropertyGroup> <Import Project="$(FxCopDir)Msbuild\Microsoft.CodeAnalysis.Targets" /> <Target Name="CodeAnalysisLogHeader" BeforeTargets="RunCodeAnalysis" Condition="$(RunCodeAnalysis) == 'true'"> <Message Text="Text, Executing Code Analysis (FxCop) on $(MsBuildProjectName)" Importance="High" /> </Target> <Target Name="ReportCodeAnalysisResults" AfterTargets="RunCodeAnalysis" Condition="$(RunCodeAnalysis) == 'true' AND '$(IsRunningOnTeamCity)' == 'true'"> <Message Text="##teamcity[importData type='FxCop' path='$(MSBuildProjectDirectory)\$(CodeAnalysisLogFile)']" Importance="High" /> </Target> </Project>
Preliminary notes for FxCop 15.0 / Visual Studio 2017:
The source directories have changed a bit.
FxCop files can be copied from:
% programfiles (x86)% \ Microsoft Visual Studio \ 2017 \ INSERT PICTURE HERE \ Command Tools \ Static Analysis Tools \ FxCop
Files that need to be copied to the MSBUILD folder can be obtained from:
% programfiles (x86)% \ Microsoft Visual Studio \ 2017 \ INSERT IMAGE HERE \ MSBuild \ Microsoft \ VisualStudio \ v15.0 \ CodeAnalysis
(Edition: Professional / Enterprise. Perhaps the community, but AFAIR, has a very different path).
BatteryBackupUnit Aug 19 '15 at 11:15 2015-08-19 11:15
source share