- Operating system: Windows / Linux
- SonarLint plugin version:
- Programming language you’re coding in: dotnet
- Is connected mode used:
- Connected to SonarCloud or SonarQube (and which version): Sonarqube 9.9 LTS
And a thorough description of the problem / question:
When the sonarscanner dotnet runs, it uses the Path.GetTempPath() to get the directory for the cache location. See here:
var localCache = Path.Combine(Path.GetTempPath(), “.sonarqube”, “resources”);
sonar-scanner-msbuild/src/SonarScanner.MSBuild.PreProcessor/Roslyn/EmbeddedAnalyzerInstaller.cs at 5e6dc0ea1212faa29d0d5f5b8dae6b0683993eca · SonarSource/sonar-scanner-msbuild (github.com)
My proposal is that this path can be set using an override to a different path.
In Gitlab, when building dotnet source, you need to do the begin, compile and end steps all in one job. There is no way to do these in different steps because it’s not possible to save the cache directory as artifacts in GitLab so a next job can use it and continue with the process.
I’m confused. You filed this in SonarLint / IntelliJ Platform. And it seems that you’re actually making a suggestion about the SonarScanner for MSBuild?
Yes I noticed that, but the filters didn’t bring up anything for dotnet/msbuild. The links from the Github repo also points to here. I’d be happy if this could be moved.
I’ve moved this to the SonarQube category, since that’s what you’re analyzing to. Are you currently using the latest version of the scanner?
Thank you for moving it.
Yes we are using the latest version. Unfortunately the temp path is hard coded, as linked in my original post, so we can’t change where the temporary files are stored being used for the analysis and the end-lint process.
Thanks for the confirmation. I’ve flagged this for more specialized eyes.
Thank you. The comment in the code base states:
We want the resource cache to be in a well-known location so we can re-use files that have
already been installed (although this won’t help for e.g. hosted build agents)
I don’t know enough of the code base to try and make a change, but according to the comment, this is a known issue. It would be great if this could be changed via configuration somehow to help make this work better on hosted build agents.
Thank you for suggesting this new feature, I have opened an issue in our repository. You can track the progress of it there.
The latest, 5.15 release of the MSBuild Scanner for .NET now supports the sonar.plugin.cache.directory option to indicate a specific path for the cache location.
I believe this should fix your problem.