Tsconfig.json in build output causes error / produces noise in Azure DevOps

I have a csproj with TypeScript build:

<Project Sdk="Microsoft.NET.Sdk.Web">
...
    <PackageReference Include="Microsoft.TypeScript.MSBuild" Version="4.5.2">
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
      <PrivateAssets>all</PrivateAssets>
    </PackageReference>

There’s a tsconfig.json in the project’s root. The default build action for this file is “copy to output”. So after a build it is copied to e.g. bin\Debug\net6.0\tsconfig.json.

When building this project the sonarqube scanner is run. It gets confused by this build output and dumps an error in the build overview:

This is problematic for multiple reasons:

  • It isn’t really an error to the submitter of the PR.
  • It is not actionable to the submitter.
  • It obscures any relevant warnings the build might’ve produced.
  • It is unneeded noise.
INFO: Sensor TypeScript analysis [javascript]
INFO: Found 2 tsconfig.json file(s): [D:\a\1\s\X\bin\Debug\net6.0\tsconfig.json, D:\a\1\s\X\tsconfig.json]
INFO: Creating TypeScript program
INFO: TypeScript configuration file D:\a\1\s\X\bin\Debug\net6.0\tsconfig.json
INFO: 5 source files to be analyzed
##[error]ERROR: Error: No inputs were found in config file 'D:\a\1\s\X\bin\Debug\net6.0\tsconfig.json'. Specified 'include' paths were '["**/*"]' and 'exclude' paths were '["node_modules"]'.
ERROR: Error: No inputs were found in config file 'D:\a\1\s\X\bin\Debug\net6.0\tsconfig.json'. Specified 'include' paths were '["**/*"]' and 'exclude' paths were '["node_modules"]'.
INFO: Creating TypeScript program (done) | time=49ms
##[error]ERROR:     at createProgram (D:\a\1\.sonarqube\out\.sonar\.sonartmp\eslint-bridge-bundle\package\lib\programManager.js:65:15)
ERROR:     at D:\a\1\.sonarqube\out\.sonar\.sonartmp\eslint-bridge-bundle\package\lib\server.js:36:61
ERROR:     at Layer.handle [as handle_request] (D:\a\1\.sonarqube\out\.sonar\.sonartmp\eslint-bridge-bundle\package\node_modules\express\lib\router\layer.js:95:5)
ERROR:     at next (D:\a\1\.sonarqube\out\.sonar\.sonartmp\eslint-bridge-bundle\package\node_modules\express\lib\router\route.js:137:13)
ERROR:     at Route.dispatch (D:\a\1\.sonarqube\out\.sonar\.sonartmp\eslint-bridge-bundle\package\node_modules\express\lib\router\route.js:112:3)
ERROR:     at Layer.handle [as handle_request] (D:\a\1\.sonarqube\out\.sonar\.sonartmp\eslint-bridge-bundle\package\node_modules\express\lib\router\layer.js:95:5)
ERROR:     at D:\a\1\.sonarqube\out\.sonar\.sonartmp\eslint-bridge-bundle\package\node_modules\express\lib\router\index.js:281:22
ERROR:     at Function.process_params (D:\a\1\.sonarqube\out\.sonar\.sonartmp\eslint-bridge-bundle\package\node_modules\express\lib\router\index.js:335:12)
ERROR:     at next (D:\a\1\.sonarqube\out\.sonar\.sonartmp\eslint-bridge-bundle\package\node_modules\express\lib\router\index.js:275:10)
ERROR:     at D:\a\1\.sonarqube\out\.sonar\.sonartmp\eslint-bridge-bundle\package\node_modules\body-parser\lib\read.js:130:5
ERROR: Failed to create program: No inputs were found in config file 'D:\a\1\s\X\bin\Debug\net6.0\tsconfig.json'. Specified 'include' paths were '["**/*"]' and 'exclude' paths were '["node_modules"]'.
ERROR:     at createProgram (D:\a\1\.sonarqube\out\.sonar\.sonartmp\eslint-bridge-bundle\package\lib\programManager.js:65:15)
ERROR:     at D:\a\1\.sonarqube\out\.sonar\.sonartmp\eslint-bridge-bundle\package\lib\server.js:36:61
ERROR:     at Layer.handle [as handle_request] (D:\a\1\.sonarqube\out\.sonar\.sonartmp\eslint-bridge-bundle\package\node_modules\express\lib\router\layer.js:95:5)
ERROR:     at next (D:\a\1\.sonarqube\out\.sonar\.sonartmp\eslint-bridge-bundle\package\node_modules\express\lib\router\route.js:137:13)
ERROR:     at Route.dispatch (D:\a\1\.sonarqube\out\.sonar\.sonartmp\eslint-bridge-bundle\package\node_modules\express\lib\router\route.js:112:3)
ERROR:     at Layer.handle [as handle_request] (D:\a\1\.sonarqube\out\.sonar\.sonartmp\eslint-bridge-bundle\package\node_modules\express\lib\router\layer.js:95:5)
ERROR:     at D:\a\1\.sonarqube\out\.sonar\.sonartmp\eslint-bridge-bundle\package\node_modules\express\lib\router\index.js:281:22
ERROR:     at Function.process_params (D:\a\1\.sonarqube\out\.sonar\.sonartmp\eslint-bridge-bundle\package\node_modules\express\lib\router\index.js:335:12)
ERROR:     at next (D:\a\1\.sonarqube\out\.sonar\.sonartmp\eslint-bridge-bundle\package\node_modules\express\lib\router\index.js:275:10)
ERROR:     at D:\a\1\.sonarqube\out\.sonar\.sonartmp\eslint-bridge-bundle\package\node_modules\body-parser\lib\read.js:130:5
ERROR: Failed to create program: No inputs were found in config file 'D:\a\1\s\X\bin\Debug\net6.0\tsconfig.json'. Specified 'include' paths were '["**/*"]' and 'exclude' paths were '["node_modules"]'.

SonarScanner for MSBuild 5.5.3
Azure DevOps

Hey,

I suspect that your bin directory is excluded from the analysis, but as we rely on file system we still discover that copied tsconfig file.

As a workaround you can set sonar.typescript.tsconfigPath property to the correct tsconfig file.

We might improve the analyzer Rely on sonar file system API to discover tsconfig files · Issue #3034 · SonarSource/SonarJS · GitHub

Hello @bouke

Did you manage to fix the issue?

All the best,
Čaba