Showing posts with label App Package. Show all posts
Showing posts with label App Package. Show all posts

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!

UWP : Building UWP (or Windows) App from command line

How to build a UWP (or Windows App) from Command Line


Related Links –

First Approach: Using MSBuild  [ <path to>msbuild.exe <path to>solution/project file ]

Initial Step: Clean the Project (You can also clean the project before Rebuilding the Project)

Example:  C:\WINDOWS\Microsoft.NET\Framework64\v4.0.30319>msbuild.exe "C:\Users\Saurabh\Documents\Visual Studio 2015\Projects\SimplyNote\SimplyNote.sln" /t:Clean /p:Configuration=Release


Clean Succeeds:


Step 1: Navigate to the folder where MSBuild resides (Refer Above links for more info)

Example:  
C:\WINDOWS>cd C:\WINDOWS\Microsoft.NET\Framework64\v4.0.30319


Step 2:  Now Build the project using MSBuild

Example:
 C:\WINDOWS\Microsoft.NET\Framework64\v4.0.30319>msbuild.exe "C:\Users\Saurabh\Do
cuments\Visual Studio 2015\Projects\SimplyNote\SimplyNote.sln"


Step 3: The Build succeeds.


Step 4: Rebuilding the application (Please Note: It’s better to clean the project before Rebuilding, Refer initials step for the same)

Rebuilding Started:

Example:  C:\WINDOWS\Microsoft.NET\Framework64\v4.0.30319>msbuild.exe "C:\Users\Saurabh\Documents\Visual Studio 2015\Projects\SimplyNote\SimplyNote.sln" /t:Rebuild /p:Configuration=Release


Rebuilding Succeeded:


Other Examples:
  •            MSBuild MyApp.sln /t:Rebuild /p:Configuration=Release
  •             MSBuild MyApp.csproj /t:Clean /p:Configuration=Debug;TargetFrameworkVersion=v3.5
  •             C:\WINDOWS\Microsoft.NET\Framework64\v4.0.30319>msbuild.exe "C:\Users\Saurabh\Documents\Visual Studio 2015\Projects\SimplyNote\SimplyNote.sln" Configuration="Release"
 Second Approach :Using devenv (requires Visual Studio installed) [ devenv /build Release Solution.sln | devenv /build Debug Solution.sln ]

Step 1: Open the Visual Studio Developer Console/prompt.


Step 2: The Visual Studio Developer console/prompt opens.


Step 3: Use the devenv command to build the Solution(.sln) file. Make sure you give proper path to the solution file.
Example:    C:\Program Files (x86)\Microsoft Visual Studio 14.0>devenv /build Release "C:\Users\Saurabh\Documents\Visual Studio 2015\Projects\SimplyNote\SimplyNote.sln"


Step 4: The Build Succeeds!!


You can download the PDF of above post for easy reference from below (Hosted on Google Drive):

Hope that helps!!

UWP : How to create an Appx package using Visual Studio

Creating an Appx using Visual Studio 2015 for a UWP or Windows App

After reading this tutorial, you will be able to create appx packages(not for Windows store) that you can use to quickly deploy your apps on the Windows Phone or Tablets. Also you can share the appx with your friends so that they can try you App and appreciate your work.


This may sound very trivial to experienced Developers but may be a daunting task for the beginners.One may want to share his appx package with friends or to deploy the app quickly on to the phone. Hence I decided to write this article which may be useful for beginners. Let us directly jump into action.

Step 1:  Open the Solution(.sln) file using Visual Studio (I am using VS 2015 Professional).


Step 2: Build the project (Don't forget to select "Release" and "ARM" or as you require).


Step 3: Build Succeeded.


Step 4: Right click on the project. Go to Store => Create App Packages.


Step 5: The prompt asks whether you are making appx for store. Select NO and click Next.


Step 6: Select the output location for appx and select the type of appx you want.


Step 7: Package Creation completed. Launch Windows Certificaton Kit (If required).


Step 8: Go to the Output folder that you had mentioned and see the packages that were created.


Step 9: Use the appx as you want e.g. copy it to a windows phone and install it.



You can download the above tutorial as PDF from the following link (Hosted on Google Drive):
Download How to create Appx using Visual Studio PDF

Hope that helps !!