我有一个包含3个项目的C#解决方案。
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的统计数据,但是的统计信息缺少。相反,我注意到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中有两个单独的项目,它们都包含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想要的方式)。
是否有可能与SonarQube MSBuild运行器一起多次运行MSBuild并获得一组完整的统计信息?
发布于 2015-11-19 09:21:31
在共享应用程序中,您可以有条件地设置<SonarQubeExclude>true</SonarQubeExclude>属性,以便只在构建App.Web或App.Console时设置该属性。
您可以在附录3下的Microsoft指南中找到关于如何实现这一目标的建议,“显式地将MSBuild项目与SonarQube项目关联起来”:http://redirect.sonarsource.com/doc/sq-setup-guide-for-dotnet-users.html。
发布于 2016-05-20 19:55:12
问题可能是解决方案中有一个额外的*.sln文件。当项目文件夹中有一个旧的、休眠的.sln文件时,我遇到了这种情况。删除它解决了这个问题。
https://stackoverflow.com/questions/33788988
复制相似问题