MSBuild 找不到代码分析工具
Posted
技术标签:
【中文标题】MSBuild 找不到代码分析工具【英文标题】:MSBuild could not locate the Code Analysis tool 【发布时间】:2017-03-13 13:06:01 【问题描述】:我的 Jenkins 工作因以下错误日志而失败。请提出建议。
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\CodeAnalysis\Microsoft.CodeAnalysis.targets(289,5): error : MSBuild could not locate the Code Analysis tool at ''. If MSBuild is being run from within the "Visual Studio Command Prompt", specify the path to the Code Analysis tool by setting the FXCOPDIR environment variable. [C:\test.csproj]
Done Building Project "C:\test.csproj" (Rebuild target(s)) -- FAILED.
更新的错误日志
directory:"C:\OTA\AirSearch\BTS\src\packages\HttpWebAdapters.0.4.0.2002\lib\net35" /ruleSet:"=C:\OTA\AirSearch\BTS\.sonarqube\conf\\SonarQubeFxCop-cs.ruleset" /rule:"-C:\Program Files (x86)\Microsoft Visual Studio 12.0\Team Tools\Static Analysis Tools\FxCop\Rules" /searchgac /ignoreinvalidtargets /forceoutput /successfile /ignoregeneratedcode /saveMessagesToReport:Active,Excluded /timeout:120 /reportMissingIndirectAssemblies
* Error(s) occurred during FxCop initialization:
* An exception was raised attempting to load engine 'c:\program files (x86)\microsoft visual studio 12.0\team tools\static analysis tools\fxcop\Engines\PhoenixAnalysisEngine.dll'.
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.
at Microsoft.FxCop.Command.FxCopCommand.ProcessPlatformArgument(ArgumentDictionary argumentDictionary)
at Microsoft.FxCop.Command.FxCopCommand.Main2(String[] args)
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\CodeAnalysis\Microsoft.CodeAnalysis.targets(289,5): error MSB6003: The specified task executable "FxCopCmd.exe" could not be run. Could not load file or assembly 'Microsoft.VisualStudio.CodeAnalysis.Sdk, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. [C:\test.csproj]
Code Analysis Complete -- 0 error(s), 0 warning(s)
Done Building Project "C:\test.csproj" (default targets) -- FAILED.
The target "MvcBuildViews" listed in a BeforeTargets attribute at "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.Web.Publishing.targets (843,131)" does not exist in the project, and will be ignored.
Done Building Project "C:\test.sln" (default targets) -- FAILED.
【问题讨论】:
哪个代码分析工具失败了?声纳立方? 我不确定。我觉得它的 SonarQube 【参考方案1】:从我在您的屏幕截图中可以看到,您需要在 msbuild 调用中明确指定您最喜欢的代码分析工具的路径(例如 c.\program files\sonacube ...),或者将其路径添加到您的 PATH 环境变量(请参阅How to add path to PATH-env-var)
并且您应该确保可以定位和解决来自 VS-FXCop 的所有依赖项。最好的方法是调用 Visual Studio var bat (在我的安装中,它可以位于 C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\vcvars32.bat for VS2015 )。请确保调用正确的脚本。如果您从不同的 Visual Studio 安装中复制了 FxCop 内容,请使用此脚本。如果您已从可再发行组件安装它,请确保您已复制所有依赖项。
【讨论】:
你能帮帮我吗 很难没有完整的原始日志。如果你能以某种方式上传它会很有用。 在下面和***.com/questions/21729066/…之后我得到了更新的错误。以上是关于MSBuild 找不到代码分析工具的主要内容,如果未能解决你的问题,请参考以下文章
Visual Studio Team System 2008数据库版中是否提供了代码分析工具?