运行$ C C分析(FxCop的12.0 / 14.0)上生成代理$没有安装Visual Studio二千○一十五分之二千○一十三 [英] Running Code Analysis (FxCop 12.0 / 14.0) on build agent without installing Visual Studio 2013 / 2015

查看:689
本文介绍了运行$ C C分析(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 --> 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.

根据您要构建:

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

These are the files that i had to add to source control: (Please consider that this might 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:

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

从Visual Studio 2015年C ++ REDIST,或任何其他地方: (参见<一href="http://msdn.microsoft.com/en-us/vstudio/dn501987">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昆明植物研究所)

amd64\msdia140.dll (1349 KiB)

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

from the Global Assembly Cache (C:\Windows\Microsoft.NET\assembly\GAC_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

Msbuild\Microsoft.VisualStudio.CodeAnalysis.dll

的MSBuild \ Microsoft.VisualStudio。codeAnalysis.Sdk.dll

Msbuild\Microsoft.VisualStudio.CodeAnalysis.Sdk.dll

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

的MSBuild \ fxcoptask.dll

Msbuild\fxcoptask.dll

的MSBuild \微软。codeAnalysis.Targets

Msbuild\Microsoft.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)Msbuild\Microsoft.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>

这篇关于运行$ C C分析(FxCop的12.0 / 14.0)上生成代理$没有安装Visual Studio二千○一十五分之二千○一十三的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆