Home Articles MS Build Basics
PDF Print E-mail


I am going to use this forum for sharing my own best practices in build engineering that I believe are essential for you to be an effective build engineer. This month we will take a look at Microsoft .net and MSBuild. In the future we will cover articles on Ant, Maven and Make. I also provide a link to a related article that I published on CM Crossroads.

The Challenge

There have been many times when I had to automate a build using the robust Microsoft .net framework.QuotationThere have been many times when I had to automate a build using the robust Microsoft .net framework.Quotation
Understanding the .net framework is not easy and I have had a difficult time staying on top of this technology which, to me, truly personifies a moving target. Now to be fair, I spend much more of my time working on high end Java applications running on AIX, Solaris and Linux so I may not always stay ahead of the curve with regard to Microsoft technologies. But then again, it has been my experience that many experienced Microsoft gurus have a hard time staying on top of every aspect of this robust platform too. This has important implications for the build engineer.

Hiding Behind the IDE

Most C#/.net programmers stay within the comfort of their Visual Studio IDE which has many features and is certainly a very productive environment. The problem is that they may not even be aware of all of their compile and runtime dependencies. That is a problem. Many regulatory bodies insist that there be a separation of duties which means that the build engineer must independently build, package and deploy the application. Implicit in this requirement is that the code should be baselined (e.g. tagged, labeled) and safeguarded in a secure and reliable version control system (VCS). Relying upon the Visual Studio IDE for building does not work in this case because someone could change any number of settings making it impossible for you to build (and support) an older release (obviously needed for addressing bug fixes).

Embrace Your Command Line

This requires that you build the application from the command line and that the build scripts and procedures be documented and also placed in the version control system labeled with the same tag or label as the code.

I have had many developers look at me with a blank expression when I mentioned that I needed to have a command line procedure. My super smart colleagues spent so much time in the Visual Studio IDE that they did not even know that there was a similar build procedure that could be executed from the command prompt.

Small Example

For this article I wrote a tiny program using Microsoft Visual Studio 2008. Here is the code and the form.

sample code

sample form


If you look closely you will see that the IDE support options for a batch build. The resulting code may be found in a subdirectory used by your IDE (hint - do a "save as" and see where you saved the project and code).

You should see a Debug directory and a Release directory with the binary executable that was build.


01/15/2012  06:46 PM             7,680 myFormApp1.exe
01/15/2012  06:46 PM            19,968 myFormApp1.pdb

To test this use the IDE to (batch) "clean" - which refers to removing the binaries that were built (similar to a clean directive in Ant or Make).

Then you can use MSBuild to build the project from the command line using the .sln file which contains all of the information needed for the project. (Note that you may need to update your path to find the MSBuild.exe - mine was in C:\Windows\Microsoft.NET\Framework\v3.5)

C:\_sandboxVS\Projects\myFormApp1>MSBuild myFormApp1.sln
Microsoft (R) Build Engine Version 3.5.30729.5420
[Microsoft .NET Framework, Version 2.0.50727.5448]
Copyright (C) Microsoft Corporation 2007. All rights reserved.

Build started 1/15/2012 8:03:30 PM.
Project "C:\_sandboxVS\Projects\myFormApp1\myFormApp1.sln" on node 0 (default targets).
Building solution configuration "Debug|Any CPU".
Project "C:\_sandboxVS\Projects\myFormApp1\myFormApp1.sln" (1) is building "C:\_sandboxVS\Projects\myFormApp1\myFormApp1\myFormApp1.csproj"
(2) on node 0 (default targets).
Processing 0 EDMX files.
Finished processing 0 EDMX files.
Processing resource file "Form1.resx" into "obj\Debug\myFormApp1.Form1.resources".
Processing resource file "Properties\Resources.resx" into "obj\Debug\myFormApp1.Properties.Resources.resources".
Copying file from "obj\Debug\myFormApp1.exe" to "bin\Debug\myFormApp1.exe".
myFormApp1 -> C:\_sandboxVS\Projects\myFormApp1\myFormApp1\bin\Debug\myFormApp1.exe
Copying file from "obj\Debug\myFormApp1.pdb" to "bin\Debug\myFormApp1.pdb".
Done Building Project "C:\_sandboxVS\Projects\myFormApp1\myFormApp1\myFormApp1.csproj" (default targets).
Done Building Project "C:\_sandboxVS\Projects\myFormApp1\myFormApp1.sln" (default targets).

Build succeeded.
0 Warning(s)
0 Error(s)

Time Elapsed 00:00:01.14


Now you can place the entire solution into a version control system (VCS) and test the build from the command line using MSBuild (or Nant).  Remember to create your sandbox by pulling the baselined release directly from the VCS using the locked tag or version label. Please drop me a line an tell me about your own best practices in build engineering and any topic related to configuration management and application lifecycle management (ALM)!

Here is another article that I wrote on this topic some time ago for CM Crossroads.












More articles by this author

Micro Focus Completes Acquisition of Serena Software, Inc. Application Lifecycle Management Acquisition Boosts Micro Focus’s DevOps Capability ROCKVILLE, Md., May 2, 2016 /PRNewswire/ -- Micro Focus (LSE: MCRO.L) today announced the completion of its acquisition of Serena Software, a leading provider of Application Lifecycle Management (ALM) software, under the terms of the definitive agreement disclosed on March 22, 2016. "Our customers continue to look at DevOps as a way to deploy critical applications and services quickly and with greater reliability to meet business demands," said Stephen Murdoch, CEO, Micro Focus. "The Serena acquisition extends our ability to help customers meet these challenges so they can drive greater innovation faster with lower risk." According to industry analyst firm Gartner, "DevOps implementations utilize technology, especially automation tools, that can leverage an increasingly programmable and dynamic infrastructure from a life cycle perspective."1  The experience and expertise which the Serena business brings will enable Micro Focus to help its customers develop and release applications and services faster, with greater speed and accuracy. Serena adds capabilities in software application development; software configuration and change management; and business process management to Micro Focus's portfolio of ALM solutions spanning mainframe environments, distributed systems and cloud. The combination of Micro Focus and Serena allows companies to better: Design and build business applications and services with greater accuracy, reliability and predictability; Continuously deploy existing core business applications on a wider variety of platforms to meet changing business needs; and Improve the speed and efficiency of new business services through automated release and deployment solutions. About Serena Software Serena is among the largest Application Lifecycle Management vendors with more than 2,500 enterprise customers. Serena helps the highly regulated large enterprise move fast without breaking things – increasing velocity of the software development lifecycle while enhancing security, compliance, and performance. More information is available at www.serena.com. About Micro Focus Micro Focus (LSE: MCRO.L) is a global enterprise software company helping customers innovate faster with lower risk. Our software helps customers build, operate and secure IT systems that bring together existing business logic and applications with emerging technologies to meet increasingly complex business demands. For more information, visit: www.microfocus.com. 1I&O Must Combine ITIL and DevOps to Deliver Business Value for Bimodal IT," by George Spafford and Ian Head, March 18, 2016.
Hi, I am excited to invite you to subscribe to our new online publication which provides guidance on Configuration Management Best Practices, Agile Application Lifecycle Management (including videos) and, of course DevOps. Our publication explains hands-on best practices required to implement just enough process to ensure that you can build software and systems that are reliable and secure. Based upon our new book, Agile Application Lifecycle Management - Using DevOps to Drive Process Improvement, the Agile ALM DevOps Journal seeks to promote a dialogue that is really needed in the industry today. We will discuss practical approaches to implementing the Agile ALM using DevOps best practices including continuous integration, delivery and deployment. We will also discuss process improvement strategies that work in large organizations that must comply with federal regulatory guidelines, along with smaller teams that may very well grow as they become successful. We are taking this journey together and our goal is to ensure that you have a voice and can share your experiences along with learning from other colleagues too. Enjoy Leslie Sachs's amazing column: Personality Matters and Bob Aiello's column: Behaviorally Speaking. We will also report on major incidents where organizations clearly need to improve on their ability to develop and deliver software effectively, including the recent Southwest systems glitches which resulted in thousands of flights being cancelled and thousands more being delayed. We will also bring you exciting technical product announcements such as jfrog's new xray, which helps to scan your runtime objects, including docker images, for vulnerabilities. This is an exciting time to be in the technology field. Join the revolution! You can submit your articles for publication to share your own knowledge and experience!  Subscribe to receive your copy and register so that you can comment online Bob Aiello http://www.linkedin.com/in/BobAiello @bobaiello, @agilealmdevops, @cmbestpractices This e-mail address is being protected from spambots. You need JavaScript enabled to view it  
Copyright © 2017 CM Best Practices. All Rights Reserved.
Joomla! is Free Software released under the GNU/GPL License.

Product News

Live Online Training