Problem with SonarQube Analysis for Asp.Net Website Project

Hi Team,
I am trying to add my Asp.Net Website solution for SonarQube Analysis. In this solution, We have 1 main website project and other class library project referred by this main Website project. Analysis runs fine and I can see all referred class library projects in analysis report site. But I am not seeing main website project.
My guess is as this website is not generating any dll, analysis is not happening. please suggest.

thanks,
kavitha

hi @Andrei_Epure
Can please help me on above question.

hi @Kavitha_Lingampally

Please don’t nominate people to answer. It’s enough to bump the thread and it will show up in the news feed in case we miss a topic.

First :

  • what is the version of SQ?
  • what is the version of the plugin?
  • what is the version of MSBuild you are using?
  • what is the version of Scanner for MSBuild you are using?
  • what are the commands you are running to do the analysis?
  • are you running all commands from the same folder?

Second:

  • please give us the verbose output of the build command msbuild /v:d
  • please give us the verbose output of END command (please run SonarScanner.MSBuild.exe begin /k:“MyProject” /d:sonar.verbose=true as the begin step, and please attach the output of END step)

Hi Anderi,
Please don’t nominate people to answer. It’s enough to bump the thread and it will show up in the news feed in case we miss a topic.-Sorry,I won’t do next time.

  • what is the version of SQ? 7.9.3
  • what is the version of the plugin?
    SonarC#-7.15.08572
  • what is the version of MSBuild you are using?16.6.22303
  • what is the version of Scanner for MSBuild you are using? 4.9.0
  • what are the commands you are running to do the analysis?

going folder where my solutions is:
1.SonarScanner.MSBuild.exe begin /k:“PaHubUAT2” /n:“PaHubUAT2” /v:“1.0” /d:sonar.verbose=true
2.“C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\MSBuild.exe”
3.SonarScanner.MSBuild.exe end

  • are you running all commands from the same folder? yes
    I created sample sln and I added one website called Test1,below I attached output files

please see attachments
MSBUILD_OUTPUT.txt (33.3 KB) MSBUILD_OUTPUT1.txt (2.5 KB)

For same Sample sln,I added C# project.Now solution has one webprj and C# project.
MSBUILD_OUTPUT914.txt MSBUILD_OUTPUT915.txt (34.2 KB)
Thanks,
Kavitha

1 Like

Hi @Kavitha_Lingampally . Does the web project contain C# or VB. NET files? Are these files references in the csproj project?

If the files are not build by msbuild, then our Roslyn analyzer for C# and VB .NET cannot work. Roslyn analysis happens during msbuild time.

If you use the Scanner for MSBuild for the web project, any file inside (e.g. html, css, js) must be referenced in the csproj project.

Hi Andrei,

Please let me know ,is it sonar supports Asp.net Website?
I saw below on Sonar documentaion
Known Limitations

  • MSBuild versions older than 14 are not supported.
  • Web Application projects are supported. Legacy Web Site projects are not.
    Thanks.

Hi @Kavitha_Lingampally,

Asp.net Website can be either a Web Application project (that is supported) or a Legacy Web Site project (that is not supported).

It seems that the question is if you have web application or web site.

  • Web application: There’s a csproj/vbproj file in your project
  • Legacy Web Site: There’s no csproj/vbproj, common classes are in App_Code directory.

If you have a Legacy Web Site, you can add csproj that will include * paths and analyze that.

1 Like

Hi Pavel,

Our website is legacy web site Project.
Please let us know steps or documentation how to add .csproj to legacy website and analyze it.

Thanks,
Kavitha

Hi Kavitha,

In best case scenario, you should Convert a Web Site Project to a Web Application Project. That will make your life and development way easier.

If not:

  • Create new solution with one empty project.
  • Copy SLN and CSPROJ file into your project.
  • Open your solution and include all files into the project
  • Make the project buildable. You might need to exclude some *.aspx.cs or *.ascx.cs files due to conflicting class names.
  • Follow usual steps of analyzing .NET project with scanner for MSBuild.

Hope this helps
Pavel