How To Analyze GitHub Unity Project with Sonar Cloud?

Hello, I’m a junior dev, so please be patient if my questions are stupid.

I have this Unity C# project:

It’s therefore a C# project in GitHub and I configured a CI system using Unity Actions: to build my project and run the tests on the cloud after a push or pull request. So far so good.

My problem is I’m trying to figure out exactly what I need to do in order to analyze this project via Sonar Cloud. I can’t seem to figure out what commands or what are the steps required. Any help will be welcomed!

Hey there.

To analyze C# files, you must use the SonarScanner for .NET.

The problem, as I understand it, is that Unity projects aren’t typically built in the same fashion as most C# projects (using dotnet build or MSBuild.exe)

One workaround might be creating a “dummy” project that can be built using common .NET build tools which contains all your C# files that you use just to execute the analysis. Tools like this could be helpful in achieving this: GitHub - microsoft/MSBuildForUnity: MSBuild integration in Unity

You could also try following up on this thread where another user was trying the same:

Sorry if it’s not too helpful – our ecosystem just doesn’t well support analysis of Unity projects at this time.