运行$ C C分析(FxCop的12.0 / 14.0)上生成代理$没有安装Visual Studio二千○一十五分之二千○一十三二千、一十、没有安装、FxCop

由网友(孤念)分享简介:FxCop的10后微软停止出货的FxCop的一个单独的安装程序。官方可以当前安装Visual Studio二千零一十五分之二千零十三后只运行code分析(FxCop的12.0 / 14.0)。但是,我们坚定的关于不上生成代理安装Visual Studio(安装需要,然后被关在同步与我们已经得到了对开发商的计算机等...

FxCop的10后微软停止出货的FxCop的一个单独的安装程序。 官方可以当前安装Visual Studio二千零一十五分之二千零十三后只运行code分析(FxCop的12.0 / 14.0)。 但是,我们坚定的关于不上生成代理安装Visual Studio(安装需要,然后被关在同步与我们已经得到了对开发商的计算机等)。

After FxCop 10 Microsoft stopped shipping a separate installer for FxCop. Officially one can currently only run code analysis (FxCop 12.0 / 14.0) after installing Visual Studio 2013 / 2015. However, we are adamant about not installing Visual Studio on the build agents (the installation needs then to be kept in-sync with what we have got on the developer computers etc.).

那么我将如何去有关获取FxCop的12.0 / 14.0〜上生成代理,$ P $工作pferrably无需安装其他东西吗?我会接受加入了一些二进制文件和的MSBuild文件到源代码控制,但。 否则:有没有办法只能使用Visual Studio安装的FxCop东西二千零十五​​分之二千零十三安装

So how would i go about getting FxCop 12.0 / 14.0 to work on a build agent, preferrably without installing anything else? I would accept adding a few binaries and msbuild files to source control, though. Otherwise: Is there a way to only install the FxCop stuff using Visual Studio 2013 / 2015 installer?

请注意:我们使用的TeamCity作为构建服务器

Note: we are using Teamcity as build server.

推荐答案

! 对于的FxCop 12.0 / VS2013看到这个答案 !!

!! For FxCop 12.0 / VS2013 see this answer !!

prerequisites:

Prerequisites:

的MSBuild 14.0 - >安装微软构建工具2015 的Visual C ++可再发行的Visual Studio 2015年的 86 (x86版本始终是必需的,这取决于构建64 REDIST可能需要以及如果缺少错误信息可能是神秘的,例如 System.IO.FileNotFoundException:找不到,无法加载文件或程序集Microsoft.VisualStudio。codeAnalysis.Interop.dll或它的某一个依赖。指定的模块找不到。)。而不是安装整个REDIST的,你也可以单独复制所需的DLL,但在这一点上,我不知道需要哪些。这是相当棘手和费时,找出哪些是完全缺失的。 MSBuild 14.0 --> Install Microsoft Build Tools 2015 Visual C++ Redistributable for Visual Studio 2015 x86 (the x86 version is always required, depending on the build x64 redist may be required as well. If it is missing the error message can 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 could also copy the necessary DLLs separately, but at this point i don't know which are needed. It's quite tricky and time consuming to find out which ones are exactly missing.

根据您要构建:

在相应的Windows SDK,例如的Windows 10 SDK 在适当的.NET SDK /目标(.NET框架4.6 SDK包含在Windows 10 SDK)

这些都是我不得不添加到源代码控制的文件: (请考虑,这可能违反了一些许可协议)

These are the files that i had to add to source control: (Please consider that this might violate some license agreements)

(source control)toolsFxCop14
│
├[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:

%PROGRAMFILES(86)%微软的Visual Studio 14.0 团队TOOLS 静态分析工具 FxCop的

从Visual Studio 2015年C ++ REDIST,或任何其他地方: (参见http://msdn.microsoft.com/en-us/vstudio/dn501987) msdia140 x86和x64复制到:

from Visual Studio 2015 C++ redist, or any other place: (also see http://msdn.microsoft.com/en-us/vstudio/dn501987) copy msdia140 x86 and x64 to:

msdia140.dll(1057昆明植物研究所)

msdia140.dll (1057 KiB)

AMD64 msdia140.dll(1349昆明植物研究所)

amd64msdia140.dll (1349 KiB)

从全局程序集缓存( C: WINDOWS Microsoft.NET 组装 GAC_MSIL _NameOfTheAssembly _ )安装了VS2015的计算机,副本以下DLL文件: (请确保该dll是14.0版本!)

from the Global Assembly Cache (C:WindowsMicrosoft.NETassemblyGAC_MSIL_NameOfTheAssembly_) of a computer where VS2015 is installed, copy the following DLLs to: (Make sure the DLLs are version 14.0 !)

的MSBuild Microsoft.VisualStudio。codeAnalysis.dll

MsbuildMicrosoft.VisualStudio.CodeAnalysis.dll

的MSBuild Microsoft.VisualStudio。codeAnalysis.Sdk.dll

MsbuildMicrosoft.VisualStudio.CodeAnalysis.Sdk.dll

所有的%PROGRAMFILES(x86)的文件%的MSBuild 微软 VisualStudio中 v14.0 codeAnalysis

的MSBuild fxcoptask.dll

Msbuildfxcoptask.dll

的MSBuild 微软。codeAnalysis.Targets

MsbuildMicrosoft.CodeAnalysis.Targets

此外我调整了项目的MSBuild文件(* .csproj的)如下(提示:我略有方式偏离我previously做到了与VS2013这不是因为FxCop的14作品不同,而是因为这样子我可以用的NuGet包包括FxCop的,并使用标准的NuGet功能的.targets文件导入的.csproj):

Additionally i adjusted the project msbuild file (*.csproj) as follows (Hint: i'm slightly deviating from the way i previously did it with VS2013. It's not because FxCop 14 works differently but rather because this way i can include fxcop by a nuget package and use standard nuget functionality for .targets file import to .csproj):

<!-- Microsoft.CSharp.targets import is contained in csproj by default. This just goes to show the sequence -->
<Import Project="$(MSBuildToolsPath)Microsoft.CSharp.targets"/>

<!-- now this must be added -->
<Import Project="$(ProjectBuildScriptDir)Custom.CodeAnalysis.targets"/>

而这正是我们的定制codeAnalysis.targets包括:

And this is what our Custom.CodeAnalysis.targets contains:

<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

    <!-- Code analysis settings. -->
    <PropertyGroup>
        <!-- this must reference the path where you copied the FxCop stuff to -->
        <FxCopDir>..FxCop14</FxCopDir> 
        <CodeAnalysisCulture>en-US</CodeAnalysisCulture>
        <CodeAnalysisRuleSet>$(SolutionDir)FxCop.ruleset</CodeAnalysisRuleSet>
        <!-- you can and should use another condition here. Otherwise code analysis will be run on every build in VS as well. -->
        <!-- in my build setup i do something like Condition=IsRunningOnTeamCity => true -->
        <RunCodeAnalysis>true</RunCodeAnalysis> 
        <CodeAnalysisTreatWarningsAsErrors Condition="'$(IsRunningOnTeamCity)' != 'true'">true</CodeAnalysisTreatWarningsAsErrors>
    </PropertyGroup>

    <Import Project="$(FxCopDir)MsbuildMicrosoft.CodeAnalysis.Targets" />

    <Target Name="CodeAnalysisLogHeader" BeforeTargets="RunCodeAnalysis" Condition="$(RunCodeAnalysis) == 'true'">
        <Message Text="Text, Executing Code Analysis (FxCop) on $(MsBuildProjectName)" Importance="High" />
    </Target>

    <!-- Report code analysis results to TeamCity -->
    <Target Name="ReportCodeAnalysisResults" AfterTargets="RunCodeAnalysis" Condition="$(RunCodeAnalysis) == 'true' AND '$(IsRunningOnTeamCity)' == 'true'">
        <Message Text="##teamcity[importData type='FxCop' path='$(MSBuildProjectDirectory)$(CodeAnalysisLogFile)']" Importance="High" />
    </Target>

</Project>
阅读全文

相关推荐

最新文章