【发布时间】:2016-02-20 17:10:47
【问题描述】:
我有一个包含 3 个项目的 C# 解决方案。
- App.Console\App.Console.csproj
- App.Web\App.Web.csproj
- App.Shared\App.Shared.csproj
App.Console 和 App.Web 均引用 App.Shared。目前,我分别构建每个项目,因为它们的 MSBuild 参数略有不同。
我目前的构建过程如下
MSBuild.SonarQube.Runner.exe begin /k:"MyApp" /n:"My App" /v:"1.0"
msbuild.exe msbuild App.Console\App.Console.csproj /t:'Rebuild' /p:Configuration=Release /p:OutDir=C:\Out\Console
msbuild.exe msbuild App.Web\App.Web.csproj /p:DeployOnBuild=True /p:DeployDefaultTarget=WebPublish /p:WebPublishMethod=FileSystem /p:DeleteExistingFiles=True /p:publishUrl=C:\Out\Web
MSBuild.SonarQube.Runner.exe end
我看到了 App.Console 和 App.Web 的统计信息,但是,App.Shared 的统计信息缺失。相反,我注意到 SonarQube 运行器输出中的警告。
警告:重复项目 GUID:“21889c3d-d9c4-40d6-a4e4-971735d19ee2”。检查项目是否仅针对单个平台/配置构建,并且项目 guid 是否唯一。 SonarQube 不会分析该项目。项目文件:C:\Projects\MyApp\App.Shared\App.Shared.csproj
我相信这个警告是我问题的根源。
如果我执行以下操作:
MSBuild.SonarQube.Runner.exe begin /k:"MyConsoleApp" /n:"My Console App" /v:"1.0"
msbuild.exe msbuild App.Console\App.Console.csproj /t:'Rebuild' /p:Configuration=Release /p:OutDir=C:\Out\Console
MSBuild.SonarQube.Runner.exe end
MSBuild.SonarQube.Runner.exe begin /k:"MyWebApp" /n:"My Web App" /v:"1.0"
msbuild.exe msbuild App.Web\App.Web.csproj /p:DeployOnBuild=True /p:DeployDefaultTarget=WebPublish /p:WebPublishMethod=FileSystem /p:DeleteExistingFiles=True /p:publishUrl=C:\Out\Web
MSBuild.SonarQube.Runner.exe end
我现在在 SonarQube 中有 2 个单独的项目,它们都包含 App.Shared 的统计信息。这很糟糕,因为此信息在两个项目之间重复,并不能准确地为我的解决方案提供整体技术债务。
通过仅构建解决方案,我已经能够在一个项目中获得所有三组统计数据:
MSBuild.SonarQube.Runner.exe begin /k:"MyApp" /n:"My App" /v:"1.0"
msbuild.exe msbuild App.sln /t:'Rebuild' /p:Configuration=Release
MSBuild.SonarQube.Runner.exe end
这不理想因为构建解决方案并没有按照我需要的方式构建 Web 项目,因此我必须在 SonarQube 完成之后进行第二次构建(构建方式我需要它,而不是 SonarQube 想要的方式)。
是否可以结合 SonarQube MSBuild 运行器多次运行 msbuild 并获得一组完整的统计数据?
【问题讨论】:
标签: c# .net sonarqube sonar-runner sonarqube5.1