在VSTS项目构建中运行代码分析器 [英] Run Code Analyzers in VSTS project build

查看:62
本文介绍了在VSTS项目构建中运行代码分析器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在VSTS(托管TFS)中,我具有使用MSBuild的构建定义.我真正想要的是让请求带有任何违反规则检测的注释.但是,我根本无法使分析仪正常工作.到目前为止,我已经完成了什么;

In VSTS (hosted TFS) I have a build definition which uses MSBuild. What I would really like is to have pull requests annotated with any rule violation detections. However I can't get the analysers to work at all. What I've done so far;

  1. 在要构建的项目之一中安装了Microsoft.CodeAnalysis.FxCopAnalyzers
  2. 已验证在Visual Studio中运行分析代码"确实会输出违反规则的情况
  3. 所有*.ruleset文件在自托管生成代理上均不可用,因为它仅安装了MSBuild(没有完整的Visual Studio).对于与第1点相同的项目,我还使用了自定义规则集.
  4. 我也已经在托管的构建代理(已安装VS2017)上构建了项目,但无济于事.
  1. Installed Microsoft.CodeAnalysis.FxCopAnalyzers in one of the projects that gets build
  2. Verified that running "Analyze Code" in Visual Studio does output rule violations
  3. All the *.ruleset files are not available on the self-hosted build agent, as it only has MSBuild installed (no full-fledged Visual Studio). For the same project as in point 1, I've also used a custom ruleset.
  4. I have also build the project on a hosted build agent (which has VS2017 installed), but also to no avail.

通过以上所有内容,VSTS中的构建日志/构建概述未列出任何违反规则的情况.据我了解,代码分析应自动运行,并且输出应显示在构建概述页面(即https://MYSITE.visualstudio.com/MYPROJECT/_build/index?buildId=XXX&_a=summary&tab=details)上.

With all of the above, the build log / build overview in VSTS doesn't list any rule violations. It's my understanding that the code analysis should be run automatically and the output should appear on the build overview page (i.e. https://MYSITE.visualstudio.com/MYPROJECT/_build/index?buildId=XXX&_a=summary&tab=details).

推荐答案

代码分析"设置基于配置和平台,因此您需要确保使用与启用了代码分析的配置和平台相同的配置和平台来构建项目.构建.

The Code Analysis setting is based on the configuration and platform, so you need to make sure you build the project with the same configuration and platform that enabled code analysis on build.

您还可以在 MSBuild 任务的 MSBuild参数中进行指定:

You also could specify it in MSBuild Arguments of MSBuild task:

/p:RunCodeAnalysis=true;CodeAnalysisRuleSet=..\RuleSets\MyMixedRecommendedRules.ruleset

这篇关于在VSTS项目构建中运行代码分析器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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