젠킨스 msbuild 로 컴파일 하기


n my previous article “Getting Started with Jenkins and GitHub” I showed you how to create your first Jenkins job and download the source of your project from GitHub. If your projects are stored in TFS you can read how to setup your Jenkins job for TFS here: “Integrate Jenkins with Team Foundation Server“. The next logical step in your build will be to build your solution or projects. I will guide you how to do it via MSBuild as build engine and NuGet for downloading the necessary packages.

Install Jenkins Plugins

  • Click Manage Jenkins link
  • Click Manage Plugins link
  • Click Available tab and type the name of the desired plugin in the filter text box
  • Install the MSBuild Plug-in – This plugin makes it possible to build a Visual Studio project (.proj) and solution files (.sln).

Configure Build Step

  • Open Manage Jenkins Page
  • Click Configure System link
  • Under the MSBuild section click MSBuild Installations… button
  • Enter Name– msbuild.exe
  • Enter default path to msbuild.exe- C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MsBuild
  • Open the configure page of your Jenkins job
  • Click Add build step button
  • Select Build a Visual Studio project or solution using MSBuild
  • For MSBuild Version  choose the configuration that you have created – msbuild.exe
  • For MsBuild Build File – enter the path for the project/solution that needs to be built in the format – ${WORKSPACE}\PhantomTube\PhantomTube.sln (${WORKSPACE} is a Jenkins variable that contains the default workspace location)
  • In Command Line Arguments – you can enter msbuild.exe arguments that you use when you build your project though command line. For example /p:Configuration=Release is going to build your project in Release mode. Or you can increase the logging verbosity, etc.

Configure NuGet Package Restoration

In order to restore NuGet packages you have a couple of options. You can try some of the available plugins. However my preferred approach is to use Windows batch command. 

First you need to download the NuGet.exe which you are going to use for the operation. The newest versions don’t support the restore command so you need to download a version that supports it. My preferred for the moment is 2.81.

You need to paste a command like the following in the Command text box: “C:\J\Nuget\NuGet_2.81.exe restore “C:\J\jobs\PhantomTube\workspace\PhantomTube\PhantomTube.sln“”

The step should be moved above the MSBuild step because in order the build to be successful you are going to need all package downloaded beforehand.

Now you are ready to test your setup. Open your job from the link listed on the main Jenkins page. Click the Build Now button.

If you open the console output, you can check the status of your build.


답글 남기기

이메일 주소는 공개되지 않습니다.