본문 바로가기

Languages&Library/etc

SonarQube C#프로젝트 사용법

 

 

C#프로젝트의 설정도, python에서의 사용법과 동일하다.

다만 .NET Framework의 경우에는 sonar-scanner-msbuild를 별도로 또 다운로드 받아줘야한다.

(C# 프로젝트 분석하기 정말 힘들다...)

 

https://docs.sonarsource.com/sonarqube/9.8/analyzing-source-code/scanners/sonarscanner-for-dotnet/

 

SonarScanner for .NET

The SonarScanner for .NET is the recommended way to launch an analysis for projects built using MSBuild or dotnet.

docs.sonarsource.com

 

위 홈페이지에서 다운로드 받아줘야하는ㄷ[

.NET Framework의 버젼에 맞게 설치해줘야 하고, 필자는 .NET Framework 4.6+를 다운로드 받았다. 

 

다운로드 받은 파일을 압축해제 하면 SonarScanner.MSBuild.exe가 있는 것을 확인 할 수 있다.

 

 

 

sonarqube에서 프로젝트를 만드는 것은 python과 같이 동일한 방식으로 진행해주면 된다.

 

 

① SonarScanner.MSBuild.exe begin /k:"csharp" /d:sonar.host.url="http://127.0.0.1:9000" /d:sonar.login="token_key"

② MsBuild.exe /t:Rebuild

명령어를 그대로 입력하면, 배치파일을 찾을수 없다는 에러가 남,

→  ② 명령어를 그대로 치면 위와같은 에러가 뜬다. 그래서 본인이 설치한 MsBuild.exe의 경로를 입력해주면 아래와 같이 실행이 된다. ex) "C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\ MsBuild.exe" /t:Rebuild

경로에 띄워쓰기가 있는 경우도 에러가 뜨므로, " 따옴표로 경로를 입력해야한다.

 

 

 

③ SonarScanner.MSBuild.exe end /d:sonar.login="token_key"

 

 

3번째 명령어 까지 입력하면 EXECUTION SUCCESS가 뜨고, total타임 등이 뜬다.

그리고 sonarqube 웹페이지에 분석결과가 뜨게된다.

 

'Languages&Library > etc' 카테고리의 다른 글

SonarQube Python사용법  (0) 2023.11.09
SonarQube 설치 시 NET START 및 SonarQube is stopped에러  (2) 2023.11.08
SonarQube Window 설치  (0) 2023.11.08
빌드 후 이벤트 파일 복사  (0) 2023.11.06