I have a C# solution with 3 projects.
- App.Console\App.Console.csproj
- App.Web\App.Web.csproj
- App.Shared\App.Shared.csproj
Both App.Console
and App.Web
reference App.Shared
. Currently, I build each project separately as they have slightly different MSBuild arguments.
My current build process is as follows
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
I see statistics for both App.Console
and App.Web
, however, statistics for App.Shared
is missing. Instead, I notice a warning in the SonarQube runner output.
WARNING: Duplicate project GUID: "21889c3d-d9c4-40d6-a4e4-971735d19ee2". Check that the project is only being built for a single platform/configuration and that that the project guid is unique. The project will not be analyzed by SonarQube. Project file: C:\Projects\MyApp\App.Shared\App.Shared.csproj
I believe this warning is the root of my problem.
If I do the following:
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
I now have 2 separate projects in SonarQube which both contain statistics for App.Shared
. This is bad because this information is duplicated between the two projects and does not accurately give me an overall technical debt for my solution.
I have been able to get all three set of statistics in one project by building the solution only:
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
This is not ideal because building the solution does not build the web project the way I need, thus I must do a 2nd build after SonarQube completes (build the way I need it, not the way SonarQube wants it).
Is it possible to run msbuild
multiple times in-conjunction with the SonarQube MSBuild runner and get one set of complete statistics?