尝试使用管道jenkinsfile进行构建时,找不到框架“ .NETFramework,Version = v4.6.1”的参考程序集。错误

时间:2019-05-15 12:17:57

标签: asp.net-mvc github build jenkins-pipeline

我尝试了另一个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'
    }
    }

    }
  }

1 个答案:

答案 0 :(得分:0)

例外为您提供了答案:

  

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

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