收集共享项目的统计信息 [英] Gather statistics for shared project

查看:129
本文介绍了收集共享项目的统计信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含3个项目的C#解决方案.

I have a C# solution with 3 projects.

  • App.Console \ App.Console.csproj
  • App.Web \ App.Web.csproj
  • App.Shared \ App.Shared.csproj

App.ConsoleApp.Web均引用App.Shared.目前,我分别构建每个项目,因为它们的MSBuild参数略有不同.

Both App.Console and App.Web reference App.Shared. Currently, I build each project separately as they have slightly different MSBuild arguments.

我当前的构建过程如下

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.ConsoleApp.Web的统计信息,但是,缺少 App.Shared的统计信息.相反,我在SonarQube运行器输出中注意到一个警告.

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.

警告:重复的项目GUID:"21889c3d-d9c4-40d6-a4e4-971735d19ee2".检查项目仅针对单个平台/配置构建,并且项目guid是唯一的. SonarQube将不会分析该项目.项目文件:C:\ Projects \ MyApp \ App.Shared \ App.Shared.csproj

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.

如果我执行以下操作:

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的统计信息.这很糟糕,因为此信息在两个项目之间重复,并且没有准确地给我解决方案的总体技术负担.

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

这不是理想的,因为构建解决方案并不能按照我需要的方式构建Web项目,因此我必须在SonarQube完成后进行第二次构建 (构建方式需要它,而不是SonarQube想要的方式).

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).

是否可以与SonarQube MSBuild运行器一起多次运行msbuild并获得一组完整的统计信息?

Is it possible to run msbuild multiple times in-conjunction with the SonarQube MSBuild runner and get one set of complete statistics?

推荐答案

问题可能是您的解决方案中有一个额外的* .sln文件.当项目文件夹中有一个旧的,休眠的.sln文件时,我遇到了此问题.删除它可以解决问题.

The issue might be that you have an extra *.sln file in your solution. I encountered this when there was an old, dormant .sln file in a project folder. Deleting it resolved the issue.

这篇关于收集共享项目的统计信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆