Is it possible to scan a webSITE project?

Hi,

We have a large Visual Studio solution with many projects. It is a legacy solution and therefore the main web project is a website project (not a web application project).

Sonar does not seem to see any of the files in the website project.

Is it possible to get Sonar to scan this project?

thanks,

Greg

1 Like

Hello Greg,

According to our documentation about SonarScanner for MSBuild, it is a known limitation:

Web Application projects are supported. Legacy Web Site projects are not.

Regards,

Antoine

Ok - thanks for your help.

:frowning:

In some cases, using the VS conversion feature to Web Application will success and then you can use SonarQube to scan your projects. It requires some manual effort buy worth it,

1 Like

Hello Greg,

Yes, it is possible to get Sonar to scan a website project in your Visual Studio solution. SonarQube, the code analysis tool that integrates with Visual Studio, supports analyzing website projects as well as web application projects.

To enable SonarQube to scan the website project, you need to follow these steps:

  1. Install SonarQube Scanner for MSBuild: Ensure that you have the SonarQube Scanner for MSBuild installed on your machine. You can download it from the official SonarQube website.

  2. Configure SonarQube Settings: In your Visual Studio solution, you’ll need to create a SonarQube configuration file named sonar-project.properties or sonar-project.json. This file should be placed at the root level of your website project or your solution.

  3. Define SonarQube Properties: In the configuration file, you need to define the necessary SonarQube properties, including the project key, project name, project version, and other relevant settings. You should also specify the source file paths to be analyzed. For a website project, make sure to include the correct source file paths containing your website’s code.

  4. Run SonarQube Scanner: Open a command prompt or terminal, navigate to your solution’s directory, and execute the SonarQube Scanner for MSBuild. The scanner will analyze your code and send the results to the SonarQube server.

Here’s an example of a simple sonar-project.properties file for a website project:

sonar.projectKey=my_web_project
sonar.projectName=My Web Project
sonar.projectVersion=1.0

sonar.sources=WebsiteProjectFolder
sonar.exclusions=**/*.js, **/*.css  # Add exclusions as needed

# Additional SonarQube properties can be configured based on your analysis requirements

Make sure to adjust the sonar.sources and sonar.exclusions properties according to the structure of your website project.

By following these steps and properly configuring the SonarQube settings, you should be able to scan your website project and get code analysis results in SonarQube.

If you encounter any issues during the setup or need further assistance, refer to the SonarQube documentation or seek help from the SonarQube community.

For more information check this: https://yardgearsguide.com/how-to-train-wisteria-on-a-pergola/