How to setup Jenkins with ASP .NET Core

Viewed 10854

I am trying to create a Pipeline on Jenkins, to automate my build, test and deploy process.

pipeline {
    agent any
    environment {
        myVersion = '0.9'
    }
    tools {
        msbuild '.NET Core 2.0.0'
    }
    stages {
        stage('checkout') {
          steps {
            checkout([$class: 'GitSCM', ...])
          }
        }
        stage('restore') {
            steps {
                bat 'dotnet restore --configfile NuGet.Config'
            }
        }
        stage('build') {
            steps {
                bat 'dotnet build'
            }
        }
        stage('publish') {
            steps {
              ...
            }
        }
    }
}

When trying to run the build, I get this error message from Jenkins:

'dotnet' is not recognized as an internal or external command, operable program or batch file.

What do I have to change to make this environment work?

I added my .NET CORE path etc. to the Jenkins Settings for MSBuild.

What am I missing?

1 Answers

Solved it like this:

environment {
    myVersion = '0.9'
    dotnet = 'path\to\dotnet.exe'
}

and than replaced my command with the %dotnet% variable.

Related