0

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?

M Y
  • 1,831
  • 4
  • 24
  • 52
  • What are the versions of your SonarQube and SonarC# plugin? – Val Jun 08 '17 at 15:08
  • How do you analyze your project? Using the latest scanner for msbuild and msbuild 14 I cannot reproduce the issue. Same for msbuild 12 and 15. – Amaury Levé Jun 09 '17 at 14:16
  • @hellyale is the VersionInfo.cs placed in a shared project? http://www.c-sharpcorner.com/UploadFile/7ca517/shared-project-an-impressive-features-of-visual-studio-201/ – Val Jun 09 '17 at 15:02
  • @hellyale I still cannot reproduce the problem. I created a simple solution with several projects (https://github.com/valhristov/multiple-assembly-version-bug). Can you try it and let me know if I am missing something? Since we cannot detect where you want to put your shared assembly attributes, we raise once for each project... – Val Jun 12 '17 at 16:02

2 Answers2

3

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.

M Y
  • 1,831
  • 4
  • 24
  • 52
1

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.

Val
  • 1,920
  • 1
  • 11
  • 14