1、手动添加<ProjectGuid>
.NET Core项目()(.csproj
)中没有<ProjectGuid>...</ProjectGuid>
来指定默认的模板,需要手动来添加。编辑修改.csproj
文件如下:
<PropertyGroup>
<!-- other properties here -->
<!-- SonarQube needs this -->
<ProjectGuid>{E2CEBBAF-6DF7-41E9-815D-9AD4CF90C844}</ProjectGuid>
确保将项目正确的GUID放在<ProjectGuid>...</ProjectGuid>
中
2、在PowerShell中添加
下面是在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)
}