FROM mcr.microsoft.com/mssql/server:2019-latest
RUN wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb && \
dpkg -i packages-microsoft-prod.deb && \
apt-get update; \
apt-get install -y apt-transport-https && \
apt-get update && \
apt-get install -y dotnet-sdk-5.0
CMD sleep infinity
dotnet tool install --global dotnet-sonarscanner
export PATH="$PATH:/root/.dotnet/tools"
dotnet sonarscanner begin /k:"test-key" /d:sonar.host.url="http://host.docker.internal:9000" /d:sonar.login="token"
dotnet build /src/MyProject.csproj
dotnet sonarscanner end /d:sonar.login="token"
You can do any combination of the setup above with custom paths, with standalone SonarQube server or in Docker, with the same stuff locally or in a different Ubuntu based image (the one above is Ubuntu 20.04).
When it runs dotnet sonarscanner end
it throws
SonarScanner for MSBuild 5.2.1
Using the .NET Core version of the Scanner for MSBuild
Post-processing started.
Calling the SonarScanner CLI...
Could not find 'java' executable in JAVA_HOME or PATH.
The SonarScanner did not complete successfully
Pretty much the same as "Could not find ‘java’ executable in JAVA_HOME or PATH." when scanning with Scanner for NET but I cannot reply to that thread for some reason and there are no solutions or even clues provided to what’s happening.
The information listed here is wrong https://sonarcloud.io/documentation/analysis/scan/sonarscanner-for-msbuild/ - it requires corrections in order for the copy-paste to work.
I’d like to avoid installing java onto my images/machines. The way the doc above explains it it sounds like you do not need a standalone java setup. I also tried to apply chmod 755
on /root/.dotnet/tools/.store/dotnet-sonarscanner/5.2.1/dotnet-sonarscanner/5.2.1/tools/net5.0/any/sonar-scanner-4.6.1.2450/lib/sonar-scanner-cli-4.6.1.2450.jar
and other jar
files I could find. No luck.