Nuget cache files for sonarqube-roslyn-sdk

Hi,

When I create new jar,it create old jar.I reset the following files.I clear files.How can I clear all cache?
D:\Users\VB36137\AppData\Local\Temp.sonarqube.sdk.nuget\codecracker.CSharp.1.0.2\analyzers\dotnet\cs
D:\Users\VB36137\AppData\Local\Temp\NuGetScratch

I used this plugin(GitHub - SonarSource/sonarqube-roslyn-sdk: SDK for SonarQube Roslyn Analyzer Plugins)

Thank You,
Beste Regards,

Hi @cecertemel,

I don’t fully understand your description of the problem you are having.

If you run RoslynSonarQubePluginGenerator.exe multiple times, it will create a new jar each time, replacing the pre-existing jar. However, if there is a cached version of the NuGet package under temp%\.sonarqube.sdk\.nuget then that cached version will be reused, even though a new jar file is is created.

On my machine, if I delete the files from that cache then the package will be fetched again from the original NuGet feed (which could be a local NuGet feed on the same machine).

Are you wrapping a third-party Roslyn analyzer, or are you developing your own custom analyzer?

Hi @duncanp ,
Are you wrapping a third-party Roslyn analyzer, or are you developing your own custom analyzer?
I use third party Roslyn analzer.I have the same problem in the two repos below.

I’m doing the following steps while creating new jar

  • I am replacing my Wintellect.Analyzers.dll(release dll which I added custom rule ) in C:\Users\caner\AppData\Local\Temp.sonarqube.sdk.nuget\Wintellect.Analyzers.1.0.6.0\analyzers\dotnet\cs
  • I run RoslynSonarQubePluginGenerator /a:Wintellect.Analyzers:1.6.0.0 in cmd

But it create old version jar each time.How can I create new version jar. I want to clear cached version jar.But I could not be successful.

Thank You,
Best Regards.

In the first line you mention 1.0.6.0, but in the second you say 1.6.0.0. Is that correct, or is it a typo?

Hi @ duncanp,

I’m sorry I wrote it wrong.I’m running the following command.and I follow the steps on the picture
“RoslynSonarQubePluginGenerator /a:Wintellect.Analyzers:1.0.6.0”



@cecertemel no problem, just thought I’d better check.

To make sure I understand the problem, these are the steps you are taking:

  • you’ve cloned a third-party Roslyn project and added you own rule(s)
  • you’re building the project to create the new analyzer assembly
  • you’re manually updating the contents of the analyzer .zip file under the %temp%\.sonarqube.sdk\.nuget so it contains the new analyzer assembly
  • finally, you run the RoslynSonarQubePluginGenerator.exe command.

That creates a new jar file with expected name of wintellectanalyzers-plugin-1.0.6.jar, but the jar file still contains the old version of the analyzer assembly. Is that correct?

Manually overwriting files in an existing zip folder is not the recommended way to create a jar file. However, I have tried those steps on my machine and the jar file did correctly contain the new version of the analyzer assembly.

@duncanp all the steps you said are correct.

The first time, a new jar file was created. But when I update it second time, after the first jar. I can use the first rule in sonarqube. But I can’t use the my second,third custom rule in sonarqube. Because it has first version.

Ok. Does the console output from the RoslynSonarQubePluginGenerator contain the expected number of analysis rules? e.g.

...
[DEBUG] Loaded analyzer: Wintellect.Analyzers.ReturningTaskRequiresAsyncAnalyzer
[DEBUG] Loaded analyzer: Wintellect.Analyzers.UseDebuggerDisplayAttributeAnalyzer
Loaded: 11 analyzers.
[DEBUG] Removed AssemblyResolver from current AppDomain assembly resolution.
[DEBUG] Resolving dependencies for Wintellect.Analyzers version 1.0.6.0...
Number of analyzers located in package Wintellect.Analyzers: 11
...

Did you stop and restart your SonarQube instance after installing the updated .jar file?

@duncanp yes.I restarted sonarqube.When I change the title of the custom rule I added, the Sonarqube does not detect this change.

@cecertemel I went through the steps I described above to add a single rule to a fork of the Wintellect analyzer, generate a plugin and add it to SonarQube. The new custom rule appeared as expected:

I then added two more rules, rebuilt the assembly, updated the cached zip file, regenerated the plugin and added it to SonarQube. All three custom rules are visible in SonarQube:

The fork I created is here, and this is the jar with three rules (renamed to a zip): wintellectanalyzers-plugin-1.0.6.jar.zip (479.7 KB)

I was using SonarQube Community edition v8.6.1.

It looks like the plugin generator and SonarQube are working as expected, which suggests the problem is somewhere in the process you are following.

Starting at the beginning:

  • independently of SonarQube, what happens if you try to use your modified analyzer NuGet package in VS project - do your custom rules appear?
  • Next, does the console output from the RoslynSonarQubePluginGenerator contain the expected number of analysis rules?

@duncanp

  • Next, does the console output from the RoslynSonarQubePluginGenerator contain the expected number of analysis rules?
    Yes.I see rules.But Some custom rules dont work by sonarqube.I work correctly with unittest in Visual Studuio.Sonarqube dont report for some custom rules.


Could you show step by step how you created the jar

@cecertemel I created the jar using the detailed steps I described earlier in the thread (for the record, manually updating the zip is not a good practice; a better solution is to let VS build a NuGet package for you, and use that).

Just to check, you can see all of the expected custom rules in SonarQube and can activate them?

If so, is the problem that when you perform an analysis, you are not seeing the expected issues raised in SonarQube for some rules?

@duncanp
I have the same problem. Every time i make a new version of the analyzer i proceed to do the following steps:

1)Uninstall the old version.
2)Restart the server. Once i restart the server, the rule is still there (with the plugin uninstalled)
3)Place the new version at /extensions/plugins
4)Restart the server

When performing the analysis i don’t see the expected issues raised (with all the new changes). I’ve tried it in Visual Studio using the Nuget and it works.