Search code examples
c#.netsonarqubeassemblyversionattribute

SonarQube says critical bug : provide an 'AssemblyVersion' attribute for this assembly 36 times


I am using SonarQube for the first time and a scan of my project revealed 38 bugs. 36 are the same bug:

Provide an 'AssemblyVersion' attribute for this assembly.

SonarQube says to resolve this bug I need to add

[assembly: AssemblyTitle("MyAssembly")]
[assembly: AssemblyVersionAttribute("1.2.125.0")]

before the namespace in each of the 36 files...

However, when I add it to even one file (With the correct title and version number) I get these errors in Visual Studio:

enter image description here

I read this questions and its answers and am more confused than before. I read this article about "The right way to version your assemblies" and moved my projects' AssemblyInfo.cs into a linked VersionInfo.cs file like the article suggested.

At this point I am at a loss, how do I fix these 36 bugs? What is the best practice for providing Assembly Version?


Solution

  • I was using the DEPRECIATED sonar-scanner.bat to analyze my files.

    I followed the directions to set up SoanarQube scanner with MSBuild as Amaury Leve pointed out and once I was building with MSBuild 15 the AssemblyVersion bugs all disappeared from the analysis results.