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:
https://github.com/game-ci/docker/ 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!
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
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:
I’m trying to scan Unity project via GitHub Action, using flow from Sonarcloud wizard.
I generated .sln and .cproj using Unity Hub on my MacBook.
GitHub flow uses “dotnet build BoatAttack.sln”, which fails with
C:\Program Files\dotnet\sdk\5.0.403\Roslyn\Microsoft.CSharp.Core.targets(71,5): error MSB6004: The specified task executable location "/Applications/Unity/Hub/Editor/2020.3.23f1/Unity.app/Contents/Tools/RoslynScripts\unity_csc.sh" is invalid. [D:\a\BoatAttack\BoatAttack\UnityEngine.Tes…
Sorry if it’s not too helpful – our ecosystem just doesn’t well support analysis of Unity projects at this time.