Scanning C# (Unity) project error

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.TestRunner.csproj]

It’s right, github actions worker runs on Windows, not Mac. But I have no idea what I should put into .csproj.

Hi @vitalykarasik

sorry for the late reply on this one.

Did you look into GitHub - microsoft/MSBuildForUnity: MSBuild integration in Unity?

1 Like

Thank you!

1 Like

Hi,
Any update on this issue?
Were you successful in using this method?

We are struggling getting any relevant analysis on our project (we are using bitbucket pipeline but I guess the capabilities are similar to Github actions)

No - we’re working with Codacy.

Hello @Vincent_Noel - can you share the steps that you tried to do? like build steps using MSBuild and eventual errors?

It was a long time ago, Unity is using its own way to build the c# project and I tried my best to find a way to build a unity project with MSBuild (because it is necessary in order to analyze a c# project on Sonar) which I did not manage to do.
Today I was looking at the cloud solution of Sonar and was hoping the problem found a solution but I’m not sure it did.
As of now I don’t have the time to look into it, but if someone succeed in analysing (with minimal effort and complexity) a unity project on sonar I’ll probably try again.

I believe that automatic analysis should work for a Unity project Automatic analysis | SonarQube Cloud Documentation

Did you try it out?