问题
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:
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?
回答1:
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.
回答2:
The rule is checking the assembly-level attributes that are already compiled and you should be able to follow the pattern with a linked AssemblyInfo.cs.
I think you are experiencing a bug with the issue reporting on our side, we have an open ticket about it and we are aiming at providing a fix at the end of the next week. If that's the case, you should be seeing much less reported errors with SonarLint for Visual Studio.
来源:https://stackoverflow.com/questions/44439202/sonarqube-says-critical-bug-provide-an-assemblyversion-attribute-for-this-as