0

我有很多项目,我创建了一个通用的 MSBuild 文件来运行。我正在尝试将 PVS Studio 的静态分析集成到构建中,而无需再次构建。我遵循了 PVS 网站上的一些文档,但我一定遗漏了一些东西。我这么说是因为当我构建 PVS 时,我的触发/调用似乎没有。有没有人有这方面的经验,可以帮帮我吗?

这是我的构建文件的 PVS 位。

 <UsingTask TaskName="ProgramVerificationSystems.PVSStudio.PVSStudio" 
    AssemblyFile="C:\Program Files (x86)\PVS-Studio\PVS-Studio-MSBuild.dll" />
    <Target Name="PVSStudioAnalysisBeforeCompile" BeforeTargets="ClCompile">
    <Exec Command="echo PVSStudio initiating now."/>
    <PVSStudio Condition="'%(ClCompile.ExcludedFromBuild)'!='true'" 
        Sources="@(ClCompile)" 
        BeforeClCompile="true" 
        BuildingInIDE="false" 
        TrackerLogDirectory="%(ClCompile.TrackerLogDirectory)" 
        PreprocessorPath="$(VCInstallDir)" 
        Platform="$(Platform)" 
        ProjectFullPath="$(MSBuildProjectFullPath)" 
        SolutionDir="$(SolutionDir)">
     <Output TaskParameter="SourcesAfterTlogParsing"    
        ItemName="CLCompileAfterTlogParsing" />
     </PVSStudio>
   </Target>
<Target Name="PVSStudioAnalysisAfterCompile" AfterTargets="ClCompile">
<PVSStudio Sources="@(CLCompileAfterTlogParsing)" 
    BeforeClCompile="false" 
    BuildingInIDE="$(BuildingInsideVisualStudio)" 
    PreprocessorPath="$(VCInstallDir)" 
    OutputFilePath   ="$(OutputDir)" 
    Platform="$(Platform)" 
    ProjectFullPath="$(MSBuildProjectFullPath)" 
    SolutionDir="$(SolutionDir)" />
<Exec Command="echo PVSStudio finished"/>

我相信你们都需要更多信息来解决这个问题,所以让我知道我应该为你们准备什么。

谢谢,

TBG

4

1 回答 1

1

您应该执行以下操作之一:

  1. 如果要将分析器的输出保存到文件中,则应在两个任务中将BuildingInIDE属性设置为false,还应为要保存的输出指定一个文件,例如 OutputFilePath = "$(OutputDir)"/pvs.log. 您将能够从 PVS-Studio IDE 插件/独立中查看此类日志,方法是将其打开为unparsed log.

  2. 如果您想从内部构建项目Visual StudioPVS-Studio使用插件立即将分析器结果连接到它的输出窗口,那么您应该将两个BuildingInIDE属性都设置为true(或)并通过转到并将其设置为来"$(BuildingInsideVisualStudio)"启用模式。MSBuildPVS-Studio -> Options -> Specific Analyzer Settings -> MSBuild Output Log Monitoringtrue

于 2014-09-15T11:40:16.730 回答