Friday, December 17, 2021

.NET Full framework code build using Jenkins pipeline aka Continuous Integration (CI)


 

Today I am going share how to build .NET full Framework application using Jenkins. I am not going to show all the steps but explain you at high level how you can achieve that. I have a plan to make detail steps on how to setup Jenkins pipeline, Build environment in future.

What I need

Now to building code using any automation tool is very normal. Here I will explain how to build code using Jenkins for .NET full framework application. You need to have Jenkins installed and having admin privilege to configure the tool in Jenkins. Also MSBuild installed in your machine and path is set in Jenkins.


Following are URL to get these software,



Audience : 

  • You are aware of command line MSBuild.
  • Some idea on Jenkins and Groovy script.


How I can run the MSbuild using Jenkins pipeline

  1. Make sure specific .NET MS build tool is available in Jenkins for e.g. MSBuild14, MSBuild15, MSBuild16 etc. As name suggested lower build versions is having support up to specific .NET full framework.

  2. Jenkins is able to Checkout the code from any Source Control like Git, TFS etc and that is setup already done in Jenkins before build the code.

  3. You can use standard pipeline steps(no coding required) or groovy script to build the code

Build using Freestyle pipeline

Open your Jenkins console and select Freestyle project and create it with a name.


FreeStyle Project





Once it is created, Under Build section, you will find the Msbuild option

Jenkins MSBuild Option
MsBuild Option







Then select appropriate msbuild version for your build


List of MSbuild tools configured in Jenkins





Using Groovy DSL (This gives you more flexibility from standard pipeline creation)


    1. Make sure The MSBuild is configured in Jenkins(admin has privilege to setup this)

  1. in the groovy code get the path of msbuild.exe. Make sure path of msbbuild.exe is same across the all windows node.

  2. Construct the MSBuild command in your code.

  3. Run the command using bat command. For example

    Msbuild.exe /p:Configuration=DEV /p:DeployOnBuild=True /p:PublishProfile=PubProfile.pubxml.

đŸ“”Point to Remember


  1. Note that the Msbuild switch may differ based upon type of application you are going to build like web application, Console/Windows application.

  2. Try to use nugget package reference instade of using direct dll reference from project file.

No comments:

Post a Comment