Saturday, December 20, 2008

Doing builds and running unit tests after every check-in has become a standard practice in Agile and non-Agile development teams.  Continuous Integration is the term that describes this process and helps ensure that that nothing has been broken since the last check-in.    One area that is sometimes overlooked is the code generation.    Continuous Generation, the re-generating of code / stored procedures for every check-in and build, should be considered for your TFS builds.  I believe there is a lot of benefit to generating the code with every build.  There are several benefits:

  • Table schema and stored procedure parameters can change.  How do you know that your generated objects are up to date and match the database?
  • It keeps everyone honest so they don’t break the golden rule of never editing generated code.  If the build is going to re-generate the code there’s no way to sneak the semicolon or curly bracket that you manually fix each time after generation.
  • Sometimes we generate just the class we are working on and keep the rest checked in so it doesn’t overwrite the current object.  If any changes are made to the template only this new class will have them.  The other classes will be based on the older version.
  • It gives more credibility to the generation process.  There is sometimes a feeling of nervousness when generating all of the objects.  Since generated code is never edited, you can generate the code as often as you wish.

CodeSmith Tools is the code generation tool that we use.  It offers an easy way to accomplish this from your Team Foundation Builds.   With version 3.2 and newer there is a custom build task included with the Professional edition.  Here is the online help with some information about it.

There are a couple things to consider.  The generated classes will be checked-in to source control.  You will need to check them out before you call the task and then check them back in afterwards. Also, the user guide instructions do not work quite right in the link above.  The guide explains how to use it within your visual studio project.  However, the task needs to be called from Team Build.  Here’s the basic steps and changes for your CI tfsbuild.proj file.

Step 1: Install CodeSmith Professional on your TFS build server.  This will install the MSBuild task and Targets file.   I contacted CodeSmith Tool’s sales department and this does require an additional license for the server.

Step 2: Import the CodeSmith Targets file.  Add the following line just below the import element below the <!-- Do not edit this --> comment.

<Import Project="$(MSBuildExtensionsPath)\CodeSmith\CodeSmith.targets" />

Step 3:  Add TF property in the PropertyGroup element specifying the tf.exe location to be used throughout the process.

<PropertyGroup>
  <
TF>&quot;$(TeamBuildRefPath)\..\tf.exe&quot;</TF>
</
PropertyGroup>

Step 4:  Override the AfterGet target to check out the generated file(s).  This must be called before the CodeSmith task or it will return an access denied error.  This example demonstrates one file but you can use a subfolder or naming prefix for the generated files and recursively check out all of the necessary files.

<Target Name="AfterGet">

    <Exec WorkingDirectory="$(SolutionRoot)\Main\TestCodeSmithMSBuild\"

          Command="$(TF) checkout Measure.cs"  />

Step 5:  Call the CodeSmith task to execute the CodeSmith project(s) in your solution.  This will also be called in the AfterGet target.  Currently the example in the documentation incorrectly shows the CodeSmith task using the ProjectFile attribute.  As the usage description shows, the attribute is actually ProjectFiles. 

<CodeSmith ProjectFiles="$(SolutionRoot)\Main\TestCodeSmithMSBuild\Test.csp"  />

Step 6:  Override the AfterCompile target to check in the updated generated files.  Fortunately TFS will only check in the file if there is a change.  This is good because most of the time re-generating the code should generate the same thing each time.  However, tf.exe returns a code of 1 instead of 0 and results in a partial success of the build.  Use the IgnoreExitCode=”true” to ignore this.  You could additionally update this to create a work item for any other return code.  Here’s a post with a good example of this.

<Target Name="AfterCompile" Condition="'$(IsDesktopBuild)'!='true'">

    <Exec WorkingDirectory="$(SolutionRoot)\Main\TestCodeSmithMSBuild"

          IgnoreExitCode="true"

          Command="$(TF) checkin /comment:&quot;***NO_CI***Auto-Generate&quot; /noprompt /override:&quot;Auto Generate&quot; measure.cs "/>

  </Target>

Step 7:  Undo the check out if the build fails by overriding the BeforeOnBuildBreak.

<Target Name="BeforeOnBuildBreak" Condition="'$(IsDesktopBuild)'!='true'">

    <Exec WorkingDirectory="$(SolutionRoot)\Main\TestCodeSmithMSBuild"

          Command="$(TF) undo /noprompt measure.cs"/>

  </Target>

That is it.  Enjoy!

Mike

Saturday, December 20, 2008 10:49:44 PM (Central Standard Time, UTC-06:00)  #    Comments [0]  | 
Sunday, December 07, 2008

I admit that while I have been keeping up with Csla information, I haven't had the opportunity to use the newer versions of Csla.  We have an opportunity to use Csla with a client so I'm using this chance to catch up on it and get some practical experience with 3.6.  I downloaded the framework and samples downloads. You can download the latest framework at http://www.lhotka.net/cslanet/Download.aspx

I was excited by how much is included in both.  The framework includes snippets, visual studio templates, and a deployment package.  Here's some highlights.

Snippets
There are several snippets included. With the new way to do properties in Csla, the editable and readonly property snippets will come in handy.  Here's the results of the "cslaprop" snippet.

private static PropertyInfo<int> NameProperty = RegisterProperty(new PropertyInfo<int>("Name", "Name"));

public int Name
{
   get { return GetProperty(NameProperty); }
   set { SetProperty(NameProperty, value); }
}

Item Templates
When you install the VSI, it installs 14 templates for almost all common Csla usages and objects.  Like the rest of the framework, the full source for the templates are included.  So customizing the templates to fit your projects needs is easy.

 

Csla Samples
I downloaded the samples project expecting to just see the Project Tracker example.  The Project Tracker is still the main example but it has been expanded to include examples for every configuration that Csla supports including WCF, Web Services, WPF, winforms, Webforms, Silverlight (requires additional Csla for Silverlight download), LINQ, DTO, Entity Framework, Workflow, etc.

In addition to the Project Tracker, there are examples for doing WPF design time support, Deep loading and saving of data, and establishing parent-child-grandchild relationships in Csla. 

I am looking forward to working through all of these examples to see Rocky's recommendations in the 3.6 version of his framework.

Mike
 

Sunday, December 07, 2008 6:17:28 PM (Central Standard Time, UTC-06:00)  #    Comments [0]  | 


A couple weeks ago I started a new and exciting chapter of my career.  After 8 great years at Farm Credit Services of America as a developer and lead developer, I took a new job as a solution consultant with a small, yet proven and experienced consultanting company called Deliveron Consulting Services.   I have no complaints about FCSAmerica and appreciate all of the oportunities that I received while I was there.  It was a great place to work and leaving was one of the hardest decisions I have had to make. I'm going to miss working with all of the great people I have gotten to know.  I felt this was the right opporturnity at the right time for me.  I'm excited to leverage all of my experiences in Team Foundation Server, CSLA.NET, code generation, configuration management, Agile, Biztalk, etc along with the leadership skills in a new environment.  In fact, I have already begun helping one of our clients convert a projects to TFS.  I'm also utilizing Team Deploy to automate their build and deploy process.  I am excited to work with more companies on implementing or improving their implementation of Team Foundation Server.

So this begins a new chapter and I am excited!

Mike

Sunday, December 07, 2008 8:29:11 AM (Central Standard Time, UTC-06:00)  #    Comments [1]  | 
Wednesday, November 12, 2008
Last week I released some minor updates to Team Deploy.  When you use Team Deploy to deploy your MSIs, it will update the build steps and show that it is deploying.  The second feature will now write any non-zero return code to the build log.  Before this, these return codes were being lost.  In the next release of Team Deploy I will build upon this and allow you to pass in an XML file contain return codes.  If they are an error, warning or information.  For errors, I will make it so it will actually fail the build.

Here's the release
http://www.codeplex.com/teamdeploy

Mike

Wednesday, November 12, 2008 10:36:56 PM (Central Standard Time, UTC-06:00)  #    Comments [0]  | 
Tuesday, October 28, 2008

If you are like me and couldn't make it to PDC this year, all of the sessions are going to be made available on Channel 9.  I'm excited for a lot of new features in VSTS 2010.  Windows Azure looks cool too.  It will be interesting to see what and how they price it.

https://sessions.microsoftpdc.com/public/timeline.aspx

Mike

Tuesday, October 28, 2008 9:11:58 PM (Central Standard Time, UTC-06:00)  #    Comments [0]  | 
Thursday, August 28, 2008

My only complaint about my Sprint HTC Mogul has been the web browser.  I upgraded to Windows Mobile 6.1 and the browser is basically the same.  I saw a blog post a few weeks ago about a new web browser in private beta called Skyfire.  In the post was a link to a video of a phone playing some Silverlight video of the Olympics on it.  I couldn't believe that it was on a smart phone!  I signed up and actually forgot about it.  Tonight I received the text message from them to sign up.  Once I ran it, I was blown away by the clean interface, speed of the rendering of the pages, and navigation options.  I watched some Flash videos and some live video from Fox News.  It was amazing.  It only took me a few minutes to get the hang of the zooming and moving.  I could tell the pages were loading fast but I didn't realize how much faster they load then the other mobile browsers.  Take a look at the head to head review of Safari, Opera, and Skyfire.  The load time of the pages are 1/10th of the other browsers!  Now you can watch YouTube videos, sign in to Exchange Webmail, watch live TV, and basically anything else you can do with your computer's browser.   The only two downsides I have found are not Skyfire's fault.  One the screen is small.  Not much you can do about that on a smart phone.  The other is the battery won't last forever.  Between watching some Sprint TV and this I was able to drain my battery.  My final test was to see how a some 2.5d Silverlight would look.  Microsoft's Mojave Experiment was just redone in Silverlight.  It was funny that it was originally done in Flash.  If you haven't seen it yet, it is a cool looking Silverlight page.  In addition it is a funny concept.  Microsoft told a bunch of Vista haters that they were about to see the new version of Windows.  Then when they turned out to love it, they told them that it was really Vista.  Anyway, back to my test.  I pulled it up on my phone in Skyfire and it worked perfectly.  The animation was smooth.  The videos were crisp and loaded fast.  The only thing I couldn't really do was the forward and backward zooming through the website.  I could click on the zoom button on the page and it worked but not as smooth as the scroll wheel on my mouse.  

Skyfire is not only the best web browser for mobile phones, it is the best application I have seen.  Up until now, I thought Orb was the best.  Signup for the private beta.  Hopefully you won't have to wait as long as I did.

Mike

Thursday, August 28, 2008 10:09:21 PM (Central Standard Time, UTC-06:00)  #    Comments [0]  | 
Friday, August 01, 2008

Next week I get to attend my second ESRI User conference.  I'm really looking forward to this.  This time I will be presenting and we are receiving a Special Achievement in GIS award.   It will be my first opportunity to speak at a national (actually international) event.

Here's our presentation:

Utilizing Image Server/ArcGIS Engine/SDE for Offline/Online Enterprise Appraisal System
http://events.esri.com/uc/2008/infoweb/OnlineAgenda/index.cfm?fa=ofg_details_form&ScheduleID=532

If you attending, stop by the session.  See you in San Diego.

Mike 

Friday, August 01, 2008 9:26:12 PM (Central Standard Time, UTC-06:00)  #    Comments [0]  | 
Friday, July 18, 2008

Our project team supports a couple large enterprise applications. We often find ourselves spending time troubleshooting production support issues.  These tasks end up taking a significant portion of time away from development.  We often put in a quick fix that satisfies the one particular condition that is causing the error.  More than we would like to admit, we unknowingly break another feature or another condition of that feature. 

Our team is working on a changing the way we fix these bugs.  Instead of fixing the bugs directly in code and then manually testing them, we are creating a test (either unit test or automated GUI test) that represents the failing condition.  This test is intended to initially fail.  Then it is the developer’s job to fix the broken test.  This is helpful for a couple reasons.  One, by being able to create a test that fails, this is good evidence that the real issue has been identified .  This should eliminate times where we "think" we see the problem and end up not fixing anything.  Secondly, the developer (and entire team if using a CI build notification process like Team Deploy) will know exactly when this is fixed.  Lastly, by adding these as tests, this condition will be tested forever, every time the tests run.  This will ensure that other fixes down the road won't break this condition of the feature. 

In addition to the benefits, this supports Agile and Test Driven Development.  Just like TDD, this starts with a broken test that the developer will fix.  The TDD term is "Red, Green, Refactor".
This isn't always an easy process.  Everyone thinks it is a good idea, but when it comes to doing it, it takes longer and the tests are often hard to create.  However, I believe the long term benefits greatly outweigh the challenges.  Let me know if works for you.

Code Smart Not Had

Mike

Friday, July 18, 2008 10:28:44 PM (Central Standard Time, UTC-06:00)  #    Comments [0]  | 
Sunday, July 06, 2008

I have begun to rewrite my website, www.doitconsultants.com (It really needs it as you can see) using CSS.  I found some

examples and was able to start.  Then, I couldn't figure out why the columns were not lining when I realized I needed to know

more than just hack my way around in CSS.  I went to the book store to find a book on CSS.  I didn't need one that explained

web development or assumed I knew nothing.  I was looking for some specifics between two and three column layouts.  I figured

it would be a hard book to find.  I grabbed 3 CSS books from the shelf and started flipping through them.   One was too basic

and another was more like a glossary.  Then, I came across Stylin with CSS by Charles Wyke-Smith.  This book immediately

caught my eye by full color pages and a lot of examples.  The book was more than just eye candy though.  The book had a

chapter of exactly what I was looking for.  He clearly explains multiple layouts, liquid flow, etc.  Like any good

book, you can download all of the examples from his book.  The best part is his examples include a css library he created

that he gives you for free.  Great book, I highly recommend this book for all web developers.

As a design challenged ASP.NET developer, most templates available from websites such as http://www.freecsstemplates.org/ have

great examples we can use, however these require some modifications to work with ASP.NET.  This book refers to Dreamweaver

but doesn't require any specific IDE.  Before I continued with my website design, I wanted to do an exercise to help me understand the examples.  So I decided to create some basic ASP.NET project templates.  I created three templates to reflect the 3 usual layouts.  Each of the templates also include a cool feature I learned from the book to round the corners using Nifty Corners at http://www.html.it/articoli/nifty/index.html.  The also include ASP.NET best practices like Master Pages, Site Maps, and Menu controls.


 1.  Three Column - Rounded Corners with Left Navigation, main center content, and a right promo area.


ThreeColumn.vsi.zip (24.52 KB) (Remove the .zip to install)


 2.  Two Column - Rounded corners with left navigation and main content.


TwoColumn.vsi.zip (23.84 KB) (Remove the .zip to install)

 

 3.  Two column with Top Navigation - Rounded corners with top navigation, left side links and main content.


TwoColumnTopNav.vsi.zip (24.11 KB) (Remove the .zip to install)

 

All of the templates come with multiple CSS layouts.

Feel Free to download these and use them for your projects.  Send me any updates or problems.  I tested them in IE7 and Firefox 3.0 and they look good in both.  Not sure about the others. 

Code Smart Not Hard

Mike

Sunday, July 06, 2008 9:16:35 PM (Central Standard Time, UTC-06:00)  #    Comments [1]  | 
Tuesday, May 27, 2008

Thanks to everyone that attended tonight's Omaha Team System User Group meeting.  I thought it went very well.  It was a good turnout and there were a lot of good questions asked.

Here are the slides from the presentation. 

TFS_Build_Automation.zip (260.07 KB)

Mike

Tuesday, May 27, 2008 9:02:56 PM (Central Standard Time, UTC-06:00)  #    Comments [0]  | 

Theme design by Jelle Druyts

Pick a theme: