Hello,
starting from mcr.microsoft.com/windows/servercore:10.0.20348.2340, I created an image with
- dotnet sdk-8.0.202-windows-x64-installer
- dotnet tool install --global dotnet-sonarscanner --version 6.2.0
- choco install -y microsoft-openjdk17 --version 17.0.10
The app is in .Net Core (net6.0)
My Dockerfile is something like:
WORKDIR "/src/foo"
RUN dotnet restore "xxx/xxx.csproj" --verbosity normal
RUN dotnet sonarscanner begin /k:"foo" \
/n:"foo" \
/d:sonar.host.url="https://sonarcloud.io/" \
/d:sonar.token="token" \
/o:"xxxx" \
/d:sonar.verbose=true \
/d:sonar.cfamily.cache.enabled=true \
/d:sonar.cfamily.cache.path="C:/temp/.sc_cache"
RUN dotnet build "foo.csproj"
RUN dotnet sonarscanner end /d:sonar.token="token"
When I build my Dockerfile, the begin is ok
Step 18/20 : RUN dotnet sonarscanner begin /k:"foo" /n:"foo" /d:sonar.host.url="https://sonarcloud.io/" /d:sonar.token="token" /o:"xxxx" /d:sonar.verbose=true /d:sonar.cfamily.cache.enabled=true /d:sonar.cfamily.cache.path="C:/temp/.sc_cache"
---> Running in 9f20db51d469
SonarScanner for MSBuild 6.2
Using the .NET Core version of the Scanner for MSBuild
Default properties file was found at C:\Users\ContainerAdministrator\.dotnet\tools\.store\dotnet-sonarscanner\6.2.0\dotnet-sonarscanner\6.2.0\tools\netcoreapp3.1\any\SonarQube.Analysis.xml
Loading analysis properties from C:\Users\ContainerAdministrator\.dotnet\tools\.store\dotnet-sonarscanner\6.2.0\dotnet-sonarscanner\6.2.0\tools\netcoreapp3.1\any\SonarQube.Analysis.xml
sonar.verbose=true was specified - setting the log verbosity to 'Debug'
Pre-processing started.
Preparing working directories...
...
04:43:18.801 Cache data is empty. A full analysis will be performed.
04:43:18.832 Pre-processing succeeded.
but the end creates an error
Step 20/20 : RUN dotnet sonarscanner end /d:sonar.token="token"
---> Running in ae91e151c163
SonarScanner for MSBuild 6.2
Using the .NET Core version of the Scanner for MSBuild
Post-processing started.
...
Writing processing summary to C:\src\foo\.sonarqube\out\ProjectInfo.log
Calling the SonarScanner CLI...
Executing file C:\Users\ContainerAdministrator\.dotnet\tools\.store\dotnet-sonarscanner\6.2.0\dotnet-sonarscanner\6.2.0\tools\netcoreapp3.1\any\sonar-scanner-5.0.1.3006\bin\sonar-scanner.bat
Args: -Dsonar.scanAllFiles=true -Dproject.settings=C:\src\foo\.sonarqube\out\sonar-project.properties --from=ScannerMSBuild/6.2 --debug <sensitive data removed>
Working directory: C:\src\foo
Timeout (ms):-1
Process id: 15936
The syntax of the command is incorrect.
Process returned exit code 255
The SonarScanner did not complete successfully
04:44:40.277 Post-processing failed. Exit code: 1
The command 'cmd /S /C dotnet sonarscanner end /d:sonar.token="token"' returned a non-zero code: 1