Typescript files are not analyzed with Scanner for MSBuild

@DVB,

Currently the Scanner for MSBuild only analyzes files that are referenced by an MSBuild project.

You have two options for analyzing your TypeScript files:

A) analyze them separately using the scanner-cli as described in the SonarTS page. Note that you would have to send the results to a different SonarCloud project; if you use the same project key for a scanner-cli analysis and a Scanner for MSBuild analysis then the results will overwrite each other.

or

B) reference the TypeScript files from an MSBuild project that is built as part of the solution.
This could either be an existing project, or a dummy MSBuild project that exists just to hook into the Scanner for MSBuild.
Referencing the files to be analysed from an existing solution is the easier option and you could do it by adding something like the following to one of your projects:

  <ItemGroup>
    <!-- Additional files we want to be analyzed by the Scanner for MSBuild -->
    <!-- Note: setting Visible to false isn't required but stops the files from appearing
         in the Solution Explorer in VS -->
    <None Include="..\SharedTs\**\*.ts" Visible="False" />
  </ItemGroup>

Creating a dummy project is more complicated as you need to configure some other settings in the project to make it work correctly with the Scanner for MSBuild. There are some pointers on how to do this StackOverflow answer.

We’d like to make this scenario easier to do and have some tickets in the backlog e.g. #443.

5 Likes