- which versions are you using
- SonarQube: 9.2.0
- Scanner: 4.6.2.2472
- SonarScanner for MSBuild: 5.4.0.40033
- what are you trying to achieve
- I want to get resharper to work with sonarqube for a Unity Project
- what have you tried so far to achieve this
If I understood correctly the current situation is
- the resharper-clt-plugin is not maintained anymore and it cannot be installed from the marketplace. (I haven’t tried to manually install it)
- it should also not be needed anymore, as resharper cli (inspectcode) can be used as roslyn analyzer (maybe?)
In this post, @OlivierK says that
PS: Resharper was initially NOT a roslyn based analyzer, it was ported to roslyn recently. You must run that ported version to get the expect outcome.
Sorry I am rather new to the topic and don’t know how to tell if a resharper version is a roslyn analyzer, or where to find it.
I have so far tried to download a few different versions of resharper as zip, and then basically had the ci run
mono /opt/sonar-scanner-msbuild/SonarScanner.MSBuild.exe begin \
-k:"$SONAR_PROJECT_KEY" \
-d:sonar.host.url="$SONAR_HOST_URL" \
-d:sonar.login="$SONAR_TOKEN" \
-v:"$SONAR_SNAPSHOT_VERSION"
#msbuild Assembly-CSharp-Editor.csproj
#msbuild Assembly-CSharp.csproj
/opt/resharper/inspectcode.sh \
--toolset-path=/usr/lib/mono/msbuild/Current/bin/MSBuild.dll \
-o="${SONAR_TMP_PATH}resharper.xml" \
--exclude="Assets/ThirdParty/**" \
--exclude="Assets/Plugins/**" \
--build \
"$BUILD_NAME.sln"
mono /opt/sonar-scanner-msbuild/SonarScanner.MSBuild.exe end -d:sonar.login="$SONAR_TOKEN"
This fails with
The SonarScanner for MSBuild integration failed: SonarQube was unable to collect the required information about your projects.
Possible causes:
- The project has not been built - the project must be built in between the begin and end steps
- An unsupported version of MSBuild has been used to build the project. Currently MSBuild 14.0.25420.1 and higher are supported.
- The begin, build and end steps have not all been launched from the same folder
- None of the analyzed projects have a valid ProjectGuid and you have not used a solution (.sln)
It should not be reason 3. or 4.
In the resharper docs I read that resharper itsself will build the solution - so I assume it is not reason 1. (but maybe this fails somehow, the logs are quite big, i am not sure about this)
When I uncomment one of the msbuild lines above, it appears to work, but:
The msbuild step reports things like for example private field with Unitys [SerializeField] attribute as unassigned (CS0649).
One of the reasons for using resharper is, that with its Unity plugin, it will not report these false positives.
However, while resharper does properly write its analysis to resharper.xml, sonarscanner doesnt pick anything up, I see none of the issues in sonarqube (I would attach a log file, but with 4.3MB it is just above the limit).
So I believe, the resharper Version that I do have is not a roslyn-analyzer.
Does a usable roslyn-analyzer Version of resharper exist?
All I have found is this repository which seems has been abandoned in 2019.
Is there still a chance for me to get ti to work?
Edit:
Also, if I hat a Roslyn analyzer or would write some hack that transforms the report to the generic import-format, I could still not use the issues in a quality gate - that would be rather sad. Is there any way to make that work?