Sunday, March 20, 2016

UWP : Continuous Integration of UWP(or Windows) Apps using Jenkins

Automating the building of UWP(or Windows) Apps using Jenkins




Continuous Integration is the de-facto standard in almost every company to take care of the automated building of code, running test cases and informing the stakeholders about the status of the build. This is what should happen to UWP and Windows Apps too!! Isn't it ? But unfortunately it's not that easy to achieve. It took me around 4 days to get everything in order and I was able to achieve what the post title suggests.

That is why I decided to come up with this post that may be helpful to many engineers out there. Before we start I must mention that it's good to have a basic Idea of how to build an App using Command line. If you are really interested, it could be found here -


Now without wasting a second, let's jump into the process :

Step 1: Go to your Jenkins Portal and click on New Item on the left.  


Step 2: Select Freestyle Project and give an Item Name and then click on OK.


Step 3: This is the place where you do the configuration stuff e.g. Source Code Management, etc. Give a Description if you want.


Step 4: This is where the fun begins. Scroll down to Build and click on Add Build Step => Execute Windows Batch Command.


Step 5: This step is basically for restoring Nuget packages before the project is actually built. Enter the following in the Command box:

NuGet.exe restore "Path_To_Solution" -ConfigFile "path_To_Nuget_ConfigFile" –NoCache

 In my case it looks like:


Step 6: Again Click on Add Build Step and click on Windows PowerShell [Please Note: For this you should have PowerShell plugin for Jenkins Installed].


Step 7: This step is basically for the building of the UWP Project. Add the following code to the Windows PowerShell Command box:


#############################################################################
# Path to Msbuild tool
# $msbuild = "[Path to MsBuild.exe. See below for reference]"
$msbuild = "C:\Program Files (x86)\MSBuild\14.0\bin\MSBuild.exe"
set-alias msbuild $msbuild
# solution settings
# $sln_name = "[Path to Solution File. See below for reference]"
$sln_name = "C:\Users\Saurabh\Documents\Visual Studio 2015\Projects\uwptry\uwptry.sln"
$vs_config = "Release" 
$vs_platfom = "ARM"
 # call the build method
Write-Host "Building solution`n" -foregroundcolor Green
msbuild $sln_name /t:Build /p:Configuration=$vs_config /p:Platform=$vs_platfom /v:q /nologo
#############################################################################


This is how it looks when both the build steps are added:


Step 8: Click on Save.


Step 9: Now Click on Build Now on the left side.

Step 10: The build process starts. The build is in progress.


 Step 11: If it’s a Sunny day out and you have always done good deeds, the build is successful just like in my case J. If the ball is red in color, build failed L. 


Step 12: Click on the Build number (#1 in my case). Now click on Console output to see the build process.

Step 13: As we can see from the Console output that the build was successful. We can also infer other important information from the Console output.


You can download the above tutorial as PDF from the link below (Hosted on Google Drive):
Download Continuous Integration of UWP(or Windows) Apps using Jenkins PDF

And we are done! Hope that helps.
Thanks!

No comments:

Post a Comment

Thanks for your valuable comment