首页 > 解决方案 > gitlab ci yaml 为 dontnet 框架和 .net 核心配置

问题描述

我有一个 .net 解决方案,它同时具有.Net 框架.net 核心项目。在我的 gitlab-ci.yaml 中运行带有图像图像的“dotnet build”时失败: mcr.microsoft.com/dotnet/core/sdk:latest

错误:/usr/share/dotnet/sdk/3.1.412/Microsoft.Common.CurrentVersion.targets(1177,5): error MSB3644: The reference assemblies for .NETFramework,Version=v4.6.1 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks

下面是我的 yaml 脚本,

sonarqube-check:
  stage: quality
  image: mcr.microsoft.com/dotnet/core/sdk:latest
  variables:
    SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar"  # Defines the location of the analysis task cache
    GIT_DEPTH: "0"  # Tells git to fetch all the branches of the project, required by the analysis task
  cache:
    key: "${CI_JOB_NAME}"
    paths:
      - .sonar/cache
  before_script:
      - git submodule update --init
  script: 
      - "apt-get update"
      - "apt-get install --yes openjdk-11-jre"
      - "dotnet tool install --global dotnet-sonarscanner"
      - "export PATH=\"$PATH:$HOME/.dotnet/tools\""
      - "dotnet sonarscanner begin /k:\"tst_one_app_AXrhff7NXe4Qltg-o5pk\" /d:sonar.login=\"$SONAR_TOKEN\" /d:\"sonar.host.url=$SONAR_HOST_URL\" "
      - "dotnet build"
      - "dotnet sonarscanner end /d:sonar.login=\"$SONAR_TOKEN\""
  allow_failure: true
  only:
    - merge_requests
    - master
    - develop
    - branches

使用“ dotnet build ”命令,我的解决方案中的所有 .net 核心项目都在构建,但我唯一的 .Net 框架项目因上述错误而失败。

标签: .net.net-coresonarqubegitlab-cigitlab-ci-runner

解决方案


推荐阅读