首页 > 解决方案 > 未找到框架“.NETFramework,Version=v4.6.1”的参考程序集。尝试使用管道 jenkinsfile 构建时出错

问题描述

我已经尝试了另一个 docker 文件来使构建工作没有任何帮助.. iam 使用 asp.net-mvc5

当我尝试从詹金斯构建时出现错误:

Restore completed in 2.44 sec for /opt/bitnami/apps/jenkins/jenkins_home/jobs/Team21/jobs/Project/workspace/WebAppTest/WebAppTest.csproj.

/opt/bitnami/apps/jenkins/jenkins_home/jobs/Team21/jobs/Project/workspace/WebApplication2/WebApplication2.csproj(482,3): error MSB4019: The imported project "/opt/bitnami/apps/jenkins/jenkins_home/jobs/Team21/jobs/Project/workspace/WebApplication2//MSBuild/Microsoft/VisualStudio/v14.0/WebApplications/Microsoft.WebApplication.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.

/usr/share/dotnet/sdk/2.2.203/Microsoft.Common.CurrentVersion.targets(1183,5): error MSB3644: The reference assemblies for framework ".NETFramework,Version=v4.6.1" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend. [/opt/bitnami/apps/jenkins/jenkins_home/jobs/Team21/jobs/Project/workspace/WebAppTest/WebAppTest.csproj]



Build FAILED.



    0 Warning(s)

    2 Error(s)

管道 jenkins 文件 iam 使用:

pipeline {
     //Use the following docker image to run your dotnet app.
     agent { docker { image 'mcr.microsoft.com/dotnet/core/sdk:2.2.203- 
  alpine'} }

     environment {HOME = '/tmp'} 
     stages {

     // Get some code from a GitHub repository
       stage('Git') {
       steps{
          git 'https://github.com/user/project.git'
      }
     }
   //     stage('Dotnet Restore'){
    //      steps{
          //  sh "dotnet restore"
      //    }
      // }

     stage('Build') {
     steps {
     sh "dotnet build"
    }
  }
   stage('Unit Tests') {
    steps {
      sh 'dotnet test'
    }
    }

    }
  }

标签: asp.net-mvcgithubbuildjenkins-pipeline

解决方案


例外是为您提供答案:

要解决此问题,请为此框架版本安装 SDK 或 Targeting Pack

您缺少要在 Jenkins 上执行的任务的正确框架,因此您必须安装它。


推荐阅读