28 March 2009

Code Camp 11 Presentations

CodeCamp_thumb The Intro to MSBuild presentation and example code can be found at http://manicprogrammer.com/cs/files/folders/st_jean/entry8576.aspx.

The Extending the TFS Warehouse presentation and example code can be found at http://manicprogrammer.com/cs/files/folders/st_jean/entry8590.aspx.

Thanks to everyone that attended.

26 March 2009

VSTS DB Pro: Why does my “Data” menu have duplicate entries?

This is a known issue that arises when you install the VSTS DBPro GDR release while Visual Studio is open.  Microsoft is working on a fix but won’t have it in the VSTS DB Pro GDR v2 release (now out as an RC).  I’ve come across this on my VMs as well as some client installations.  It is frustrating.  I have yet to find a way to clean it all up. 

I should have known that Gert Drapers (THE Data Dude) would have a workaround for me. 

Is your Visual Studio Team System 2008 Database Edition GDR installation confused?
Does your menu suffer from multiple instance disorder?

Here is what you can do about it.

  1. Make sure that Visual Studio (devenv.exe) is closed.
  2. Start an elevated command prompt.
  3. Run the following two commands:

    "%ProgramFiles%\Microsoft Visual Studio 9.0\DBPro\DBProRepair.exe" RemoveDBPro2008
    "%ProgramFiles%\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe" /ResetUserData

Now restart Visual Studio again, and the problem should be cured.”         -Gert Drapers

So make sure you have Visual Studio closed when installing the DB Pro GDR so you won’t have this problem in the first place.

25 March 2009

Book Review: Inside the Microsoft Build Engine: Using MSBuild and Team Foundation Build

Quote for the Mediacover ;-)

“Wow!  This is the book that I wish I had written.  Sayed and William have covered the topic’s depth and breadth with enough illustrations and code examples to make any developer productive with MSBuild and Team Build.  No Experience Required. “

Disclaimer

First, let me start by saying that I have no affiliation to the authors or Microsoft Press.  I purchased my copy of the book from Amazon.com and have been in no way influenced in my opinion other than by the book itself.

I’m writing this review because I feel that this book is an essential tome if you are serious about using MSBuild and/or Team Build to automate your build process and are serious about delivering quality applications to your users/customers.  I have been on the fence about writing a book on this subject for a couple of years now but have been daunted by the time and energy it takes to “do it right”.  Well now I am relieved to say that I no longer have to.  This book covers the topic more thoroughly that I could have. 

Review

The book is broken down into 2 sections, MSBuild first then Team Build later. 

MSBuild

The MSBuild section starts off with a “Quick Start” section for those of us too impatient to read the whole thing prior to creating our “Hello World” build.  This section holds the “essential elements” of any MSBuild project.  It describes Project files, Properties, Item Groups, Targets, Tasks, the MSBuild command-line and how they relate together all in 18 pages (including code and screen caps).  I really liked this section as it is always difficult teaching these concepts in a linear order since they are interdependent.  You can’t really talk about Tasks until you have introduced Targets, Targets rely on Project files which are run through the MSBuild command-line.  You get the picture.  They give a cohesive view of the MSBuild eco-system, what goes where and how they relate.

Once you have a taste for that, they go on to do “Deep Dive – Part 1” which covers “everything Property” including Reserved Properties, Command-Line Properties, Environment Variables as Properties and Dynamic Properties (sounds like a scene from Forrest Gump…Command-line shrimp, Reserved shrimp, Dynamic shrimp, …).  We then jump into Items, their Metadata and Transformations.  By the end of this you have a good appreciation for how you convey data to your Tasks and Targets. 

The “Deep Dive – Part 2” builds on the prior chapter to go deeper into Dynamic Properties and Items.  One of the best nuggets of the book can be found here.  On pages 60 & 61 they show the "MSBuild Order of Evaluation” which is essential to all but the most trivial MSBuild script.  Up until this point I knew the basics of the evaluation order but had never been able to find a definitive order.  This was the first time I knew that there was much I didn’t know but sadly not the last.

After we finish the MSBuild Deep-dives the book moves onto some more advanced topics, creating and consuming Custom Tasks.  The text walks you through creation of a task, handling Inputs and Outputs both in the Task code and in the MSBuild code and wrapping up any command-line tool in its own Task thus getting better control than the <Exec> task affords.  The chapter ends by showing you how to Debug your Custom Task in Visual Studio.  This last part of the chapter will save you time and frustration when creating your own tasks.

Moving on, we come to a discussion of the Standard Loggers and the creation of Custom Loggers.  As with the Custom Task chapter, you get a thorough treatise on the creation and usage of loggers in MSBuild.  The code samples (which can be downloaded) give you the basis for creating your own loggers or you can just compile and use theirs.

Now we come to Part III, Advanced MSBuild Topics.  This section is broken across 2 chapters, Batching and Incremental Builds and External Tools

Batching is a process whereby MSBuild looks at an Item list and groups its elements based on some metadata attribute’s values.  This is a very powerful feature of MSBuild which differentiates it from tools like NAnt (or other xAnt-based systems).  With Batching we can pass an Item list to a Task and have it loop over the elements performing the Task once per element or once per Metadata attribute value.  Like the section titles says, it’s an Advanced Topic but one that opens the full power of MSBuild up to you.  I have been struggling with understanding all of the ins-and-outs of this feature for a couple of years.  They did a good job of explaining it and now i think I’m finally “getting it”.

MSBuild has an Incremental Build feature which, when configured, will allow the Targets to look at the date/time stamp of the source files and the target binaries and make a decision to compile a project if any of the source files are newer than the target binary (or if one of the binary’s dependencies has been recompiled).  There’s more to it but you get the idea.  MSBuild can also partially build targets.  These optimizations can make a large, unwieldy build more manageable.

The end of this section give advice on how to create reusable MSBuild scripts that let you leverage some build functionality across multiple builds while keeping maintenance to a single script file.  It also shows how to integrate the NUnit testing framework and FxCop code analysis tools into your build, scripts and all.

Sayed ends the MSBuild part of the book with a bang!  Part IV is the MSBuild Cookbook which gives practical applications like Setting the Assembly Version, Building Multiple Projects, Handling Error, Replacing Values in Config files (read: fixing web.configs per environment), Starting and Stopping Services, Encrypting web.config, and a bunch more.  These two chapters lay out many of the common activities you perform in a build process while also showing real world examples of usable Targets and Tasks.

Team Build

After getting a good grounding in MSBuild you are ready to take on Team Build.  This part of the book follow the same pattern as the MSBuild sections by starting with the “Team Build Quick Start”.  When you finish going through this section you will have seen all of the basic pieces of Team Build and ensured that your TFS and Build agent environment is configured correctly.

The “Deep Dive” section is truly “deep”.  It describes the default build process and then shows how you can customize the defaults to bring in your project’s specific steps.  Need to customize the Clean process?  It’s in there.  Want to package your website into a Zip file?  No problem.  All the overridable “hook” Targets that Microsoft left in the process are described along with those Targets that you shouldn’t touch.  Each and every Target in each build step is described along with how to skip them if you want to.  Need to compile a VB6 app?  Just skip the standard Compilation step and add your call to VB6’s compiler in the AfterCompile target.  Now that’s helpful.

It get’s even “deeper”.  What do you do if your build needs to run tests that show a dialog on-screen?  Check out page 310 for a discussion on Running Interactively.  There’s a few pages on configuring SSL communication between the TFS App Tier and your Build Agent.  There’s also a section on Enabling Parallel Builds so that you can take advantage of MSBuild’s ability to use multiple CPU cores to run parts of a build in parallel.  In real terms this means that you can set up your build to run the Debug and Release versions of your app at the same time on a single machine.  This can significantly reduce the overall time of your build.  Good stuff!

Once you have put that stuff to good use you can learn about using the Team Build API which allows you to interrogate TFS and the Team Build services.   From this basis you could create a web page that allows “Build Self-Service” where someone could queue up a build without using Team Explorer.  you could also write an app that balances the build load among multiple Build Agents like the Team Foundation Build Load Balancer.  You could even use it to query the build history and display that information on a build dashboard like the Team Build Screensaver.

Beyond that the Team build section is true to the format laid out earlier.  There is a “Team Build Cookbook” section that goes into detail (down to screenshots and download URLs) on how to hook in Sandcastle for API Documentation generation, how to configure a Build Agent at a remote site to use a TFS Proxy server to speed up the Get portion of the build, and how to add your own custom Build Steps to the Team Build log window. 

Most organizations have a need to package and deploy the outputs of the compilation process.  The section on “Packaging and Deployment” shows you how to hook into Team Build at the appropriate point with your specific packaging steps (the examples Zip up the binaries) and copy them to some location for deployment.  The is a specific distinction between “deployment of the outputs of the build (or the package of them) to a drop location” and “deployment to an environment”.  The examples show how to deploy to the drop folder only although you could use the Zip code, a Copy task and the section on using (the excellent) PsExec tool in MSBuild to create a basic automated installation.

Summary and Opinions

While I may sound like a shill for the authors and publisher, I really do believe what I’ve written.  In fact, I bring the book with me to most of my consulting engagements and recommend it to my clients.  It’s useful when read from cover-to-cover or when used as a reference. 

So go out and buy a bunch of copies and make Sayed and William the first technical authors to get rich off writing a book. ;-)

15 March 2009

TFSAdmin Tool v1.4 Beta Released – Now Supports SQL Server 2008

TFSAdminCapture Michael Ruminer has announced the v1.4 Beta release of the TFSAdmin tool on Codeplex.  This release adds support  for setting permissions on SQL Server Reporting Services 2008. 

It is being release as a Beta to denote that it still needs further testing but is “stable.”  It was important to get this release into the community because v1.3 choked on SSRS 2008 installations.  Please kick the tires and check the engine before putting into a Production setting.

“We just release the 1.4 beta of TFS Admin Tool on Codeplex. It’s the first release in over a year. Its big feature is that is provides support for SQL Server 2008 which had not been previously supported. The 1.4 final version will follow shortly as will hopefully a 1.5 and just as important to me a 2.0 version to start to be worked on in parallel to the 1.x releases.”       - Michael Ruminer

09 March 2009

Mocking TFS objects…The TFS Adapters Project on Codeplex

TFSAdapter

I just received an email from Martin Danner, Team System MVP, announcing a new project on  Codeplex ( Team Foundation Adapters ) that implements Interfaces and Adapters for the TFS API objects.  Why is this important?  Because being able to mock dependencies is a core tenet of unit testing.  This project allows us to create robust Unit Tests for apps that extend the TFS system.  Here’s the crux of the announcement:

Team Foundation Adapters make it easier to do proper unit testing of applications that utilize the Team Foundation Server SDK , by providing a simple mechanism for mocking the commonly used sealed classes in the API, which cannot otherwise be mocked.

This is not vaporware folks. This project contains a working implementation, complete with sample unit tests. The project does not cover the entire Team Foundation API just yet, But it establishes a clearly defined baseline that will grow as needed.

Please have a look at the project and let me know what you think of this approach. If you like it, be sure to tell your friends about it. “                                   - Martin Danner

08 March 2009

TFS AdminTool v1.4 Under Development…and v2.0 in the works!

The TFS Admin Tool project on Codeplex has started back up.   TFSAdminCapture

The first order of business it to fix some glaring bugs and get a v1.4 out the door.  Michael Ruminer is the new “Primary Coordinator external to Microsoft” and is looking to get more activity from the wider TFS Community.  I’ve jumped on board as a development contributor and am working on fixing the “TFS Admin doesn’t work with SSRS 2008” bug (not as easy a task as I’d initially thought).

The key takeaway here is that we are looking for new blood on the TFS Admin Tool Team.

  • If you have some interest in this tool, or better yet, some expertise (we like both) please join up.
  • If you have ideas for features or fixes, please let us know on Codeplex.

Here’s the “startup notice” from the project site:

“3-05-08-Forthcoming Release
We will be creating a new release whose primary goal is to address
work item 18247- "Error with TFS 2008, SQLServer 2008 on Windows 2008" but the release will also include a few additional bug fixes/enhancements that are already in process or that can be fit in within the time box to fix 18247. This time box is as of yet undefined but the delivery target date will be defined within the next week When this release is complete we'll start another iteration to address a larger set of defects and enhancements and will continue on until no one finds value in adding to the tool any longer.

There will be some additional wiki pages added to assist in planning and current discussions that have kicked off this effort will be moved to that location and to inside the forum for wider participation. Speaking of wider participation, I would like to invite anyone and everyone to contribute. Right now the best mechanism is grab the code, make the contribution you'd like and upload a patch. I want to get much wider contribution. There are a lot of users out there and a lot of scenarios and a lot of people with good stuff to contribute. So send it on. “      - Michael Ruminer

06 March 2009

Windows Home Server Restore CD getting BSOD STOP 0x0000007b - Fixed

This post is to raise the awareness of a fix to the Windows Home Server Restore CD. 

I spent a number of hours researching and trying unsuccessfully to get the RTM version of the Restore CD to work on pair of Dell Studio (15 and 17) laptops that had hard drive replacements; more on that another time.  :(  From my research I also found that a number of HP, Toshiba and Lenovo laptops also had this issue.

Problem

You have a computer with SATA drives (hard drive and optical) or external USB optical drive and you need to restore the machine from backup using the Windows Home Server Restore CD.  During the boot process you get a BSOD with STOP 0x0000007B code.  This stop code indicates an INACCESSIBLE_BOOT_DEVICE.

Issue 

The RTM version of the WHS Restore CD doesn’t have all the drivers needed to load SATA drives.  When the WinPE image loads it can’t find the drivers it needs and crashes. 

Resolution

Get the updated Restore CD.  When it boots, it will look for a folder named “Drivers” on any USB drive that is available at boot-time for additional drivers.  This is where you put your specific SATA drivers if needed.  

UPDATE (7-Mar-2009): One of the commenters on this post (Mike) mentioned that all the drivers you need can be found in your last good backup in the Windows Home Server Drivers for Restore folder.  I’ve updated the steps below to reflect this new (and very handy) information.  Thanks Mike!

Another UPDATE (7-Mar-2009):  Another commenter (Erwyn van der Meer) mentions that the Windows Home Server Drivers for Restore folder only contains 32-bit drivers.  If you are restoring a 64-bit system you will have to put your 64-bit drivers onto a USB drive yourself.  Thanks Erwyn! 

You can follow the steps below:

  1. Download the updated Windows Home Server Restore CD (version 1800)  image.
  2. Install the update to get the Restore CD image on your drive.
  3. Burn the image to a CD.
  4. Get Drivers for your computer (if needed)
    1. Download the SATA drivers for your computer from your PC manufacturer’s support site (or your DVDs)
      - or -
    2. Open your last successful backup find the “Windows Home Server Drivers for Restore” folder in the root of your backup (32-bit drivers only).
  5. Copy the SATA drivers (or the entire contents of the folder in Step 4.2) to a USB drive in a folder named DRIVERS
  6. Place Restore CD in drive on machine to be restored.
  7. Attach USB drive with drivers to machine to be restored.
  8. Power up the machine and boot from the Restore CD.
  9. Follow on-screen prompts.
  10. [Possibly] take note of the Network devices found.  It may need additional drivers for NICs.

During my restore I also had to put the Network card drivers onto a USB drive so that the Restore CD could access the NIC.  These didn’t have to be in the Drivers folder as the Restore CD did a search for them.

Hope this minimizes the headaches and anxiety for someone else.  :)

- Steve

Download

Windows Home Server Restore CD Update: http://www.microsoft.com/downloads/details.aspx?FamilyID=26881305-91cc-4f37-b1fc-3813c423df2c&displaylang=en

Original MSFT Forum Thread: http://social.microsoft.com/Forums/en-US/whssoftware/thread/ffa3e6f0-0e6e-4d02-bd42-f3e379e58f55/