Click here to Skip to main content
Licence 
First Posted 18 Mar 2003
Views 56,394
Bookmarked 12 times

Elegant, Efficient and Scheduled Builds of .NET Applications

By | 10 Oct 2003 | Article
In this article, we would try to make effective use of Tracing facilities in .NET and make cleaner builds with C# Compiler

Introduction

When we build a specified Web Application (with C#/VB.NET compiler), normally the compiler compiles them into a DLL with the same name as the web application into the bin folder. This bin folder has been designation with Execute or Script Permission and no read permission. This is to ensure that the DLL is not downloaded by anybody and decompiled. Our concern here is to optimizing the way the compiler reports back, the results to us.

Perhaps some of the thoughts might be bit redundant, but we went through the hurdles while generating the documentation with NDOC, after which, I just thought an article on this would be helpful with .NET development fraternity worldwide.

Compiler Warnings (First Level)

We normally declare identifiers at class level, method level etc. When we don't use these the compiler may point out that the specified identifier has never been used. Significant among them is the case where you have a private scope identifier, which has not been referred at all in the class and there is no public property to get/set the value for the same.
Next, when we use Try and Catch Block to catch Exception, we normally say as
   catch (Exception ThisException)
   {
      Response.Write ("There seems to be some problem. My method 
                       threw an exception");      
   }

The above block would raise a compiler warning since the identifier ThisException has never been used. Perhaps you can temporarily dump into

     Debug.Write("The class TestClass had a problem. Here are the details " 
                  +ThisException.StackTrace + " and " +
                  ThisException.Message);

     //Debug.Write is available from System.Diagnostics namespace.

The above block would be passed by the compiler without any errors/warnings. But this as it is does not serve any purpose, All these Debug.Write statements are visible within Microsoft Visual Studio .NET Debug window. And when the application rolls out into production environment, we can change the Project Build Option into Release when all Debug Symbols would be removed and a cleaner and smaller Assembly would be generated by the compiler.

There are some options like amount of ConnectionOpen and ConnectionCloses, FileStreamsOpen and FileStreamsClosed, depending upon the nature of the application itself. In these cases, you can use Tracing. Tracing, has effects only when it has been enabled from Web.Config and works till the level that it has been configured to. So if you would like to monitor number of database connections being opened and closed or amount of FileOpens and Closes as these are bit blocking operations involving more resources, you can use Tracing as it would generate enough logging information that you can use to detect, diagnose and assess the situation.

Tracing is the biggest gift in ASP.NET application compared to any other framework and is beyond the scope of discussion in this small article. Perhaps the following article is a good point of understanding on Tracing in ASP.NET. An Article on Tracing in ASPFree.com

Well! Let's come back to our original discussions. Normally it is better to heed to the compiler warnings other than ignoring them. A warning actually stands for some potential problem. Like an un-initialized object, if when used, may cause a System.NullReferenceException. Possibly, that is why, there is a compiler option like 'Treat Warnings As Errors', which when enabled, will halt compilation, even if warnings are encountered. By default, this option is off.

Compiler Warnings (with XML Document Option)

When we try to compile the project with XML document generation option, the compiler will take the responsibility of checking whether all publicly visible properties have valid XML Comments. To satisfy a proper XML generation, so that the generated CHM file with tools like NDOC etc have valid comments filled in, you may need to feed the following comment just above the publicly visible entity (method/property/identifier/enumeration), whichever is public or protected.
  <summary>
     Some sample Summary Comments Tag. Visual Studio .NET normally uses this
     to show you a description of what the method does that carries the
     summary comments.
  </summary>   

Perhaps there are a lot more Documentation Comments that needs to be used for generating a documentation comments for an application. A complete documentation of documentation comments is available from the following MSDN URL:

Changing Configurations:

Perhaps while we roll out the web application into production, it is normally a recommended option to change the Build Configuration to Release mode, since in Release configuration, a lot of debug information are not saved and the compiler tries to make application assembly as compact and as fast as possible, as far as my little knowledge could analyze.Perhaps in larger organizations, there would be seperate teams to manage this Release Configuration. But in smaller organizations, it would be the responsibility of the development team itself to manage Debug and Release Configurations. Isn't it?

Scheduled Builds

Perhaps once we configure our web application in Release Mode, we can save this Solution file and use an automated Batch File or a freeware tool like BuildIt, which can automatically take a latest version from SourceControl also and do a complete Build and sending the BuildReports to us. I had an opportunity to download BuildIt and play around it from the following URL and our team really liked it:

I think for internal test builds, the above Scheduled Builds would really be useful. Once all BuildIt reports are ok, during final deployment, a personnel can verify everything and transfer the same to the production. Isn't it?

Conclusion

I think the above article should be really useful and a good starting point to make a kind of efficient builds of the applications. The article might not be an exhaustive coverage of elegant builds and use of Traces, but I hope, it would be make a humble start in this direction.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Vasudevan Deepak Kumar

Web Developer

India India

Member

Vasudevan Deepak Kumar is from Chennai, India who has been in the programming career since 1994, when he was 15 years old. He has his Bachelors of Engineering (in Computer Science and Engineering) from Vellore Engineering College (now VIT University). He also has a MBA in Systems from Alagappa University, Karaikudi, India.


He started his programming career with GWBasic and then in his college was involved in developing programs in Fortran, Cobol, C++. He has been developing in Microsoft technologies like ASP, SQLServer 2000. For sometime, he has also been with PHP and MySQL based development in one of his previous organizations. Now currently his focus is on Microsoft .NET World (ASP.NET, C# and Whidbey)


In his past-time, he listens to polite Carnatic Music.

Web Presence


Homepage

http://www.lavanyadeepak.tk/

Blogs



Technical




Gossips



Spiritual







Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
QuestionHow it apply in existing web application PinsussAnonymous3:09 27 Aug '04  
GeneralStep outside the box Pinmemberkevinimnotspacey17:57 15 Oct '03  
GeneralIf variable is unused - then it's unused and must be removed PinsussAnonymous17:46 14 Oct '03  
GeneralRe: If variable is unused - then it's unused and must be removed PinmemberVasudevan Deepak Kumar18:27 14 Oct '03  
GeneralRe: If variable is unused - then it's unused and must be removed PinmemberMarianoP22:53 15 Oct '03  
GeneralSlow Down PinmemberBlake Coverett11:47 11 Oct '03  
GeneralRe: Slow Down Pinmemberdog_spawn2:33 12 Oct '03  
QuestionUseless? PinsussAnonymous14:15 19 Mar '03  
QuestionWhat is this? Pinmemberleppie10:04 19 Mar '03  
AnswerRe: What is this? PinmemberDeepak Kumar Vasudevan17:43 19 Mar '03  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web01 | 2.5.120517.1 | Last Updated 11 Oct 2003
Article Copyright 2003 by Vasudevan Deepak Kumar
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid