There may be situations where building a project from the command line becomes inevitable. I was put into a similar situation where I had to set up a continuous integration for Windows Projects. At this point in time I had to explore how to build projects from the command line so that I could write the required scripts for continuous integration of Windows Projects using tools like Jenkins, etc.
I will also be posting an article on how to automate the building process or achieve continuous integration for a UWP (or any windows App) using Jenkins in near future. But the perquisite is to understand how to build applications from the command line. So let’s get started.
We have two approaches to achieve what is mentioned in the title:
First Approach: Using MsBuild [ <path to>msbuild.exe <path to>solution/project file ]
Step 1: Navigate to the folder where MSBuild resides (Refer Above links for more info)
Example:
C:\WINDOWS\Microsoft.NET\Framework64\v4.0.30319>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.
Other Examples:
- MSBuild MyApp.sln /t:Rebuild /p:Configuration=Release
- MSBuild MyApp.csproj /t:Clea /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 the 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.
All the above screenshots are present in the attachment zip that you can download.
Read more articles on Universal Windows Platform: