How i Setup SonarQube Locally — .Net

How to run SonarQube locally for .Net solutions

Prerequisites

Getting Started

Configure User

#Create DB
CREATE DATABASE sonar;
#Create a user in DB with a password
CREATE USER sonar WITH PASSWORD '<password>';
#Grant, all permissions to that user
GRANT ALL PRIVILEGES ON DATABASE sonar TO sonar;

Update SonarQube Configuration

sonar.jdbc.url=jdbc:postgresql://localhost:5432/sonar

Run SonarQube

http://localhost:9000

Project Creation SonarQube

Analyze Github Repo

Execute the Scanner (.Net Core)

dotnet sonarscanner begin /k:"demo" /d:sonar.host.url="http://localhost:9000"  /d:sonar.login="ce4c4c9c407be98e8150822abbfe017b8c576848"dotnet builddotnet sonarscanner end /d:sonar.login="ce4c4c9c407be98e8150822abbfe017b8c576848"

Execute the Scanner (.Net Framework)

SonarScanner.MSBuild.exe begin /k:"demo" /d:sonar.host.url="http://localhost:9000" /d:sonar.login="43ca541c658f2f5f856e1b2a707c122b21c02ac1"MsBuild.exe /t:RebuildSonarScanner.MSBuild.exe end /d:sonar.login="43ca541c658f2f5f856e1b2a707c122b21c02ac1"

Sample Report

Senior Software Developer at Samsung | FullStack Developer Galaxy Z Flip