Note that the ProjectGuid can be found in the .sln
file if you use such a file.
The .sln
file has a long line similar to:
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Project1",
"path\Project1.csproj", "{307CB8DB-DC9C-4830-AA92-D842D89E17E0}"
In it, the first Guid (inside Project(...)
) specifies the type of the project, and you can find a "dictionary" on the web that translates each Guid there to a human-readable type. For example, {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
means "C#" project type.
But the last Guid (given after the filename) in the .sln
entry is the ProjectGuid.
So if you use an .sln
file always, also from the SonarQube runs, there should be no need to insert a Guid in the .csproj
file.
The other place the ProjectGuid can be specified is in the .csproj
. Like other answers say, it looks like this:
<PropertyGroup>
<!-- possibly other properties -->
<ProjectGuid>{307CB8DB-DC9C-4830-AA92-D842D89E17E0}</ProjectGuid>
</PropertyGroup>
So if you never use .sln
file in any context, you can just create any new Guid. In Visual Studio, you can use "Tools" - "Create GUID" - "Registry Format" to create a fresh Guid and and have it formatted correctly for this purpose.
However, from the above, it is clear that if you do use an .sln
file in some contexts (like from Visual Studio during development/maintenance), but do not use that .sln
file from the SonarQube run, then the ProjectGuid you put in the .csproj
should match the one present in the .sln
. One way you could achieve it, when creating new projects, is to first add the new project to the .sln
, then do a diff ("Compare with Unmodified" or similar) on your .sln
file using your version control software (like Git) to obtain the ProjectGuid, and copy/paste that Guid, including braces {...}
into the new .csproj
file.