Как использовать инструменты dotnet внутри контейнера?

Я экспериментирую с Visual Studio Code Remote. Я хочу использовать SonarScanner для анализа качества кода. Я следовал инструкциям и установил инструмент на хост, но когда я пытаюсь использовать его из контейнера, я получаю:

# dotnet sonarscanner -h                                    
No executable found matching command "dotnet-sonarscanner"

На хосте:

$ dotnet sonarscanner -h
SonarScanner for MSBuild 4.7.1
Using the .NET Core version of the Scanner for MSBuild

Usage: 

  SonarScanner.MSBuild [begin|end] /key:project_key [/name:project_name] [/version:project_version] [/d:sonar.key=value] [/s:settings_file]

    When executing the begin phase, at least the project key must be defined.
    Other properties can dynamically be defined with '/d:'. For example, '/d:sonar.verbose=true'.
    A settings file can be used to define properties. If no settings file path is given, the file SonarQube.Analysis.xml in the installation directory will be used.
    Only the token should be passed during the end phase, if it was used during the begin phase.

person RobertoOSantos    schedule 05.06.2020    source источник


Ответы (2)


этот пост может помочь вам!

Установить Dockerfile инструмента dotnet core

мы можем запустить глобальную команду dotnet tool внутри контейнера, установив следующую строку:

ENV PATH="${PATH}:/root/.dotnet/tools"

Докерфайл

FROM microsoft/dotnet:2.1-sdk as build-env

WORKDIR /src

COPY question-metrics-api/question-metrics-api.csproj question-metrics-api/
COPY question-metrics-data/question-metrics-data.csproj question-metrics-data/
COPY question-metrics-domain/question-metrics-domain.csproj question-metrics-domain/
COPY tests/question-metrics-domain-tests/question-metrics-domain-tests.csproj tests/question-metrics-domain-tests/

RUN dotnet restore tests/question-metrics-domain-tests
RUN dotnet restore question-metrics-api/question-metrics-api.csproj

COPY . .

#Run tests
RUN dotnet test tests/question-metrics-domain-tests/question-metrics-domain-tests.csproj

#Begin Sonar
RUN dotnet tool install -g dotnet-sonarscanner

ENV PATH="${PATH}:/root/.dotnet/tools"

RUN dotnet sonarscanner begin /k:"question-metrics-api" /d:sonar.host.url="http://sonarqube:9000" /d:sonar.login="7ed84e09a17a31e783fa8522d876e27fe4624977"
RUN dotnet build
RUN dotnet sonarscanner end /d:sonar.login="7ed84e09a17a31e783fa8522d876e27fe4624977"
person Dupinder Singh    schedule 05.06.2020