【问题标题】:How to analyze mixed versions of .NET using SonarScanner如何使用 SonarScanner 分析 .NET 的混合版本
【发布时间】:2021-06-29 18:02:06
【问题描述】:

版本
SonarQube8.5 社区

扫描仪
声纳扫描仪-msbuild-4.10.0.19059-net46.
sonar-scanner-msbuild-5.1.0.28487-net5.0.

在单个 git 存储库中,我们有两个 .NET 5 解决方案、一个 .NET 4.7.2 解决方案和一个 .NETStandard 2.0 解决方案。 .NETStandard 项目被所有其他 .NET 项目(.NET 5 和 .NET 4.7.2)引用

/MyGitRepo 
  /Common Solution       
     /Common.csproj (NetStandard 2.0) 
  /Solution1 (.NET 5) 
     All projects are .NET5.     
     References Common.csproj 
  /Solution2 (.NET 5)    
     All projects are .NET5 .      
     References Common.csproj.      
  /Solution3 (.NET Framework 4.7.2)      
     All projects are 4.7.2.     
     References Common.csproj 

我了解 .Net 4.7.2 和 .Net 5 具有不同的扫描仪。我想知道,如果我使用各自的扫描仪分析解决方案,但在两个扫描仪中使用相同的项目密钥将两个扫描仪指向同一个 SonarQube 项目,它会起作用吗?还是第二次扫描会覆盖第一次扫描的结果?

--Scan NET 5 solutions dotnet
 "C:\SonarQubeScanners\net5\SonarScanner.MSBuild.dll" begin /k:"MyProjectKey" /d:sonar.host.url="http://sonarqube.xyz.com" /d:sonar.login="myloginkey"      

  dotnet build Solution1.sln" 

  dotnet build Solution2.sln" 

"C:\SonarQubeScanners\net5\SonarScanner.MSBuild.dll" end /d:sonar.login="myloginkey" 
    
    
--Scan NET 4.7.2 solution   
C:\SonarQubeScanners\net46\SonarScanner.MSBuild.exe begin /k:"MyProjectKey" /d:sonar.host.url="http://sonarqube.xyz.com" /d:sonar.login="myloginkey" 
    
"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe" "Solution3.sln" /t:Rebuild /p:Configuration=Release 
    
C:\SonarQubeScanners\net46\SonarScanner.MSBuild.exe end /d:sonar.login="myloginkey" 

我试图避免创建两个单独的 SonarQube 项目,一个用于 .NET 5 解决方案,第二个用于 .NET 4.7.2 解决方案。
(在 SO 上为更广泛的受众转发 question) em>

【问题讨论】:

    标签: sonarqube sonarqube-scan sonarlint


    【解决方案1】:

    使用相同的键进行两次分析会使它们相互覆盖。但是,您应该只能使用一台扫描仪来分析这两个项目,例如 documented

    用于编译 Scanner for .NET(.NET Framework、.NET Core 或 .NET)的风格与构建您要分析的项目所用​​的 .NET 版本无关。

    我只需调用一次begin,编译两个项目,然后运行一次end

    【讨论】:

      猜你喜欢
      • 2019-11-15
      • 1970-01-01
      • 2020-11-11
      • 2013-11-27
      • 1970-01-01
      • 2018-08-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多