Error on scanner for Windows Docker (PowerShell) using custom escape character

Sonar seams not to handle the custom escape character set in Dockerfile.

I’m am using:

  • Azure DevOps (ALM and CI)
  • Scanner Azure Task 1.35.0
  • SonarScanner for MSBuild 5.10
  • C# .Net Framework 4.8
  • Docker for Windows

The first line of the Docker file is:

# escape=`

According to Docker documentation and and best practice for Docker on Windows the escape character is change to [`] because the default [\] doesn’t work well on Windows.

The Docker file

# escape=`

# Add virtual directory
RUN Import-Module WebAdministration; `
	New-WebApplication -Name Server -Site WebSite -PhysicalPath c:\www\WebApp;


The Sonar scanner gives these error message:

##[error]ERROR: Unable to parse file: 
file:///C:/azp_c/work/3/s/Web/Dockerfile. Parse error at position 6:0


##[error]1: # escape=`

A work around could be to write all the RUN command on separate lines, but that would add more layers in Docker and is not desired.

Hi @Wouter,

yes indeed. Currently, the Docker analyzer is not able to handle custom escaping. Fortunately, I can tell you that we are working on it right now and will support this feature in the next release.


1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.