Dan*_*iel 23 sonarqube .net-core
当您使用SonarQube构建dotnet核心项目时,您可能会在日志中遇到错误:
警告:以下项目没有有效的ProjectGuid,并且没有使用有效的解决方案(.sln)构建,因此将从分析中跳过...
你该怎么办?
Dan*_*iel 45
由于dotnet核心项目(.csproj)不会<ProjectGuid>...</ProjectGuid>在默认模板中指定标记,因此需要手动添加.
所以你需要像这样编辑.csproj文件:
<PropertyGroup>
<!-- other properties here -->
<!-- SonarQube needs this -->
<ProjectGuid>{E2CEBBAF-6DF7-41E9-815D-9AD4CF90C844}</ProjectGuid>
Run Code Online (Sandbox Code Playgroud)
确保将自己的GUID放在<ProjectGuid>...</ProjectGuid>标记内
chr*_*ett 19
这是在powershell中添加缺少的xml元素的解决方案.
$paths = Get-ChildItem -include *.csproj -Recurse
foreach($pathobject in $paths)
{
$path = $pathobject.fullname
$doc = New-Object System.Xml.XmlDocument
$doc.Load($path)
$child = $doc.CreateElement("ProjectGuid")
$child.InnerText = "{"+[guid]::NewGuid().ToString().ToUpper()+"}"
$node = $doc.SelectSingleNode("//Project/PropertyGroup")
$node.AppendChild($child)
$doc.Save($path)
}
Run Code Online (Sandbox Code Playgroud)
我想出的解决方案是构建解决方案,而不是项目文件。如果使用 Azure DevOps,请在 DotNetCoreCLI 构建步骤中使用 **/*.sln 而不是 **/*.csproj。
| 归档时间: |
|
| 查看次数: |
8415 次 |
| 最近记录: |