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

有些话、适合烂在心里 提交于 2019-12-13 08:45:07

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!