nosinovacao / dotnet-sonar

dotnet core build environment with SonarQube MSBuild Scanner integration
BSD 3-Clause "New" or "Revised" License
61 stars 34 forks source link

Missing metadata file #14

Closed survivorbat closed 5 years ago

survivorbat commented 5 years ago

Error

SonarScanner for MSBuild 4.7.1 Using the .NET Core version of the Scanner for MSBuild Pre-processing started. Preparing working directories... 08:05:10.146 Updating build integration targets... 08:05:10.163 Fetching analysis configuration settings... 08:05:12.114 Provisioning analyzer assemblies for cs... 08:05:12.115 Installing required Roslyn analyzers... 08:05:13.929 Provisioning analyzer assemblies for vbnet... 08:05:13.929 Installing required Roslyn analyzers... 08:05:13.993 Pre-processing succeeded. Microsoft (R) Build Engine version 16.3.0+0f4c62fea for .NET Core Copyright (C) Microsoft Corporation. All rights reserved.

Restore completed in 19.54 ms for /app/Case1.MVC.Test/Case1.MVC.Test.csproj. Restore completed in 19.31 ms for /app/Case1.MVC/Case1.MVC.csproj. CSC : error CS0006: Metadata file '/tmp/.sonarqube/resources/2/analyzers/dotnet/YamlDotNet.dll' could not be found [/app/Case1.MVC/Case1.MVC.csproj] CSC : error CS0006: Metadata file '/tmp/.sonarqube/resources/2/analyzers/dotnet/SecurityCodeScan.dll' could not be found [/app/Case1.MVC/Case1.MVC.csproj]

Build FAILED.

CSC : error CS0006: Metadata file '/tmp/.sonarqube/resources/2/analyzers/dotnet/YamlDotNet.dll' could not be found [/app/Case1.MVC/Case1.MVC.csproj] CSC : error CS0006: Metadata file '/tmp/.sonarqube/resources/2/analyzers/dotnet/SecurityCodeScan.dll' could not be found [/app/Case1.MVC/Case1.MVC.csproj] 0 Warning(s) 2 Error(s)

My dockerfile to reproduce

`FROM nosinovacao/dotnet-sonar AS build

WORKDIR /app COPY ./Frontend /app/

RUN dotnet restore \ && dotnet /sonar-scanner/SonarScanner.MSBuild.dll begin \ /k:survivorbat-frontend \ /d:sonar.login=(login) \ /d:sonar.host.url=(host) \ && dotnet build \ && dotnet /sonar-scanner/SonarScanner.MSBuild.dll end \ /d:sonar.login=(login)`

My .csproj file

netcoreapp3.0 bin\Debug\Case1.API.xml bin\Release\Case1.API.xml

Notes

The build works entirely without sonarscanner, I just can't find what is causing this weird manifest error, I've tried it before with my own image and wanted to try out this one, unfortunately this one has the same error.

survivorbat commented 5 years ago

Update: I tested it with a fresh project and the same error occurs

gafda commented 5 years ago

Hello @survivorbat

I've been trying to recreate your problem to no avail. Here's a summary of what I've done according to your comments so you can compare it with your notes:

I'm using...

Steps

$ dotnet new sln -n survivorbat -o survivorbat
$ cd survivorbat
$ dotnet new mvc -n frontend -o ./src/Frontend
$ dotnet sln add ./src/Frontend/frontend.csproj
$ echo "FROM nosinovacao/dotnet-sonar:19.10.1

WORKDIR /app
COPY ./src/Frontend /app

RUN dotnet restore \\
    && dotnet /sonar-scanner/SonarScanner.MSBuild.dll begin \\
        /k:survivorbat-frontend \\
        /d:sonar.login=(login) \\
        /d:sonar.password=(login) \\
        /d:sonar.host.url=(sonar-host) \\
    && dotnet build \\
    && dotnet /sonar-scanner/SonarScanner.MSBuild.dll end \\
        /d:sonar.login=(login) \\
        /d:sonar.password=(login)" >> Dockerfile

If you run SonarScanner at this point, it will fail with the following error message:

WARNING: The following projects do not have a valid ProjectGuid and were not built using a valid solution (.sln) thus will be skipped from analysis...
/app/frontend.csproj
No analysable projects were found. SonarQube analysis will not be performed. Check the build summary report for details.
Generation of the sonar-properties file failed. Unable to complete SonarQube analysis.

This means the csproj lacks the \ entry with the value present in the sln file. So you should add it to each of your csproj files and then you can run SonarScanner. For more information see: SonarScanner Docs

$ docker build --no-cache -t survivorbat:latest .

And this works just fine for me.

survivorbat commented 5 years ago

How bizarre, I'll go and investigate what the issue is with my projects

survivorbat commented 5 years ago

I just discovered something major, look at this folder: image

All of these files have windows backslashes, but why does your version work without problem?

survivorbat commented 4 years ago

Our fix: We're running the pipeline in a windows vm for now, since coverage also only works in windows anyway.

According to our professors, this is a bug in a sonarqube plugin that the server we use is running, so it has nothing to do with the dockerfile.

Sorry for not providing a 'solution' earlier, my classmates told me they found this issue and experienced the same issue.

awaescher commented 6 months ago

Seems to be related: