Ali
Ali

Reputation: 480

Using Jenkins with .NET Project in C#

I am trying to use Jenkins for my CI/CD but it is not working well for me. Jenkins trys to find the msbuild.exe. But Jenkins can not find it somehow. I always get an error in every build. Jenkins says he can not find msbuild.exe.

I already set the path of the msbuild.exe in the jenkins properties. Bit I still get an error.

I also installed the msbuild plugin.

I am using C# 7.0 with Visual Studio 2017 Professional.

My project is just a simple WinForm to test if Jenkins is working well for me or not. My Jenkins version is 2.107.2 I am using Jenkins with a BitBucket Repo. My Operating System is Windows 10. My git version is 2.15.1.windows.2.

Can someone help?

Upvotes: 3

Views: 9348

Answers (1)

Pedro Goes
Pedro Goes

Reputation: 726

If you use Jekins pipelines with generic batch files and not specific plug-ins this should work:

node {
    def YOUR_SOLUTION_CHECKOUT_PATH = "XXXX"
    def YOUR_OUTPUT_PATH = "YYYY"
    def msbuild = "C:\\Program Files (x86)\\MSBuild\\14.0\\Bin"
    stage('Build') {
        bat """chcp 65001
        \"${msbuild}\\msbuild.exe\" /t:Clean,Build \"${YOUR_SOLUTION_CHECKOUT_PATH}\" /p:OutputPath=\"${YOUR_OUTPUT_PATH}\""""
    }
}

Something around these lines should be enough for you to test if the build is working or not.

Upvotes: 1

Related Questions