Blog Home  Home Feed your aggregator (RSS 2.0)  
.Net Jonesie - Thursday, February 09, 2006
A simple programmers blog
 
# Thursday, February 09, 2006
I've been looking at some complex code that someone else wrote lately and trying to figure out how it all works (or doesn't actually).  I've been adding lots of Trace statements so I can more easily follow the flow of execution.
 
Now, I'm not sure if this is a problem for anyone else or just my addled brain but I found that Trace statements in my Web Service don't display in the Visual Studio Output window unless I step into the Web Service code from the WinForms client.  This is a real drag.  All I want to do is execute the application and later examine the process steps.
 
A simple workaround is to use the TextWriterTraceListener.  With this I can capture Trace output to a file and look at the results after execute.  You do this by adding the following section to your web.config:
 
<system.diagnostics>
 <
trace autoflush="true" indentsize="2"
>
  <
listeners
>
   <
add name="myListener"  type="System.Diagnostics.TextWriterTraceListener" initializeData="mywebapp.log"
/>
  </
listeners
>
 </
trace
>
</
system.diagnostics>
 
 
However, I also rediscovered that by default, Trace messages also get output via OutputDebugStr() and this can be viewed with a suitable Debug Viewer.  Eg:
 
 
This DebugView is free from SysInternals.com.  It captures Trace messages from .Net apps and any other apps that use OutputDebugStr(), which includes Windows.  There is one problem that I noticed immediately though.  Trace.Write() appears like Trace.WriteLine() so you may loose some of the nice formatting that you would get in a log file but I can live with this.
Thursday, February 09, 2006 9:19:04 AM (New Zealand Daylight Time, UTC+13:00)  #    Comments [0]   General | Visual Studio  | 
# Tuesday, February 07, 2006
According to Jeff Beehler - and he should know! - Team Foundatation Server RC 1 should be on MSDN very soon, like today.  If you haven't seen what's in this release then here's another post with some details.
 
At the moment I'm quite happy with Beta 3 Refresh.  It's working pretty well and is stable but I will definately be switching as soon as I can get the download.
Tuesday, February 07, 2006 10:48:59 AM (New Zealand Daylight Time, UTC+13:00)  #    Comments [0]   Team System  | 
# Monday, January 30, 2006
It's official.  CodeCamp is coming to New Zealand. 
 
CodeCamp is:
  • All about programming and software development.
  • Run by the local community for the local community.  Most speakers will be from the local community but there may be one or two overseas speakers.
  • Free!
Think of CodeCamp like TechEd without the glitz and IT stuff.
 
If you want to know more about CodeCamp in general then see the official CodeCamp wiki site.  Over the next few weeks we (the NZ .Net User Group) will be getting more information collated and details sorted, but for now, all you need to know is:
 
Where: Whitireia Community Polytechnic, Porirua Wellington
When: 22 & 23 April (Saturday and Sunday)
What: 2 whole days of pure programming sessions, discussions, workshops and fun!  Plus one or two extra-curricular events.
 
But most importantly, if you would like to present a session to CodeCamp NZ, you should get in touch with Kirk [kirk AT dot DOT net DOT nz ] or myself [peter AT dot DOT net DOT nz].
Monday, January 30, 2006 8:17:19 PM (New Zealand Daylight Time, UTC+13:00)  #    Comments [0]   NZ .Net User Group  | 
# Thursday, January 26, 2006
I saw from Peter Himschoot's blog that TechEd Europe has been split into two separate events, one for IT Pros and the other for Developers. 
 
I would love to see a developer only conference in New Zealand and TechEd is now probably big enough to split into two.  At least the last two TechEd's have sold out very quickly and Auckland does not have a bigger venue.  I'm not sure what the mix of IT Pro / Developer is - I'm guessing it's about 40/60.  A thousand or so Developers would be a good number.
 
TechEd is a very expensive event to hold so I suppose splitting it would almost double the cost, but here's some ideas to help reduce that:
  • Scrap the vendors hall as they add nothing to the content of the event (except the vendors with Segways). 
    Actually, if you just get rid of the vendors hall then Sky City would probably be big enough for a few hundred more attendees.
  • Scrap the party - the cost of this must be getting ridiculous.  I heard the rough cost of the 2003 TechEd party. 2005 must have been more.  You could buy a warehouse apartment in central Auckland and have a non-stop year long party for less! 
  • Splitting it will make things go a little quicker - maybe 2 days will be enough for each event.
  • Scrap the hands on labs and just give people the VPC images instead.
  • Make people pay for internet access.  I know what this cost for one TechEd a few years ago (2003?) and it's just horrendous.  Most people just need to check their email occasionally or surf MSDN. They can save the p0rn downloading for their hotel rooms.
  • Reduce the full ticket price by $400 and increase the corporate price by 50%.  Business can afford to pay more and send less people.  I know for some organisations that this is a junket for the staff. 
Ok, so some of these ideas may be a bit controversial but really, TechEd can't get any bigger the way it is.  It's time to think about a change.
Thursday, January 26, 2006 7:15:19 AM (New Zealand Daylight Time, UTC+13:00)  #    Comments [3]   General  | 
# Wednesday, January 25, 2006
Habbits are a bad thing.  Automatic assumptions are the root of all evil.  Challenge everything.
 
    int i = 42;
    Trace.WriteLine("The answer is " + i.ToString());
 
OR
 
    Trace.WriteLine("The answer is " + i);
 
Could have saved myself:
 
        const double TimeToPressKey = 0.3;
       
    string wastedKeyStrokeString = ".ToString()";
        int perDay = 25;
    int workingDays = 5 * 48;
    int years = 3;
        double savings = TimeToPressKey * wastedKeyStrokeString.Length() * workingDays * years;
 
Or thereabouts.
Wednesday, January 25, 2006 8:30:55 AM (New Zealand Daylight Time, UTC+13:00)  #    Comments [1]   General  | 
# Monday, January 16, 2006
It's been a great holiday.  I've done very little and I'm feeling really relaxed and stress-free on my first day back at work.  Here's a bit of a catch-up of some stuff, no particular order.
 
Some nice Team System 3rd party stuff I'm testing.  I'll report on these more thoroughly soon.
  • TeamPrise preview 4 - tried preview 3 and it's not bad - but limited
  • TeamPlain Web Access - haven't tried yet but it looks to be more extensive than TeamPrise
  • TeamLook - integrates work items with Outlook - seems to work fine so far
From the blogsphere:
What I did on my holidays:
  • Installed DotNetNuke 4.02 and used it to create 2 new sites for the NZ .Net User Group.  jobs.dot.net.nz is not far off being ready. The new NZ .Net site still has quite a bit of work to do - hopefully it'll be done around February.
  • Created a new site for a new user group.  My wife, Trish, uses Microsoft Dynamics Nav (formally known as Navision).  She is also involved with the start-up user group for this so we have created a site for this using Community Server 2.
  • Did some work on DNN 3.2.2 for Tim.
  • Did some gardening and extended the driveway.
  • Was best man at a wedding/new years eve party (a combo deal)
  • Hosted Christmas dinner and a couple of barbies for the family and friends and neighbours
  • Went to a couple of barbies
  • Went into work once to make a phone call and check when I was supposed to return to work
Roll on 2006.  I hope to:
  • Get TFS RTM installed and working
  • Get other Airways Teams using TFS
  • Expand my own team
  • Finish 1 project!  Any one will do...
  • Trips to South Africa & Redmond (maybe) again
  • Organise a community developer conference
  • Attend TechEd (maybe)
  • Organise 10 user group meetings - first one in a couple of weeks so I better get cracking on that!
  • Lose 10kg
Monday, January 16, 2006 7:32:26 AM (New Zealand Daylight Time, UTC+13:00)  #    Comments [0]   General  | 
# Friday, December 30, 2005
Microsoft are working on providing a SCC interface for TFS Source Control.  This means that any IDE that support the SCC API will now be able to use TFS Source Control.  The first cut of this for Visual Studio 6 has been released already.
Friday, December 30, 2005 7:56:49 AM (New Zealand Daylight Time, UTC+13:00)  #    Comments [0]   Team System  | 
Maybe I was expecting too much, but did anyone else find King Kong a bore?  Some parts were good, like the jungle scenes and anywhere Kong was tearing stuff up. But I swear, if I had seen one more shot of Jack Black doing his Zoolander into the camera trying to look shocked/concerned/awestruck, I would have thrown something at the screen!
 
The thing is just way too long.  Jackson could easily have cut an hour out of the movie and it would have been much better for it.  What was the point of the side story with the kid on the boat and his book?  And what about those slow motion shots - good grief! It seemed like he was going out the way to stretch the movie to 3 hours.
 
I think it's time Jackson did a real movie - something small and with drama and no CG effects and real actors - then we will really see if he's a great director or just a good project manager who got lucky.
Friday, December 30, 2005 7:33:20 AM (New Zealand Daylight Time, UTC+13:00)  #    Comments [1]   General  | 
# Tuesday, December 20, 2005
We (Airways New Zealand) are currently recruiting trainee Air Traffic Controllers.  If you are interested in pursing a life long career with a great employer then now is the time to apply. You get to work in a great environment with lots of cool techie stuff. This is not a job that suits everyone.  The entry criteria are very specific and strict - you need to have the right stuff.
 
Despite popular belief, this is not a high stress job - don't believe the Hollywood image, it's complete garbage.  If we controlled aircraft like they do in LAX (the TV show) or Moving Tin (the Movie) I would never fly again! 
 
Checkout www.airways.co.nz/careers for details.
Tuesday, December 20, 2005 9:42:29 AM (New Zealand Daylight Time, UTC+13:00)  #    Comments [2]   General  | 
# Sunday, December 18, 2005
I've had a 'fun' weekend clearing out my overloaded inbox and mucking around with the NZ .Net Web Site.
 
MSDN Flash
If you don't receive MSDN Flash, then may I suggest that now is good time.  Looking back over the flashes I've received over the last few months, I've just realised what a great resource it is.  I tend to do a lot of surfing and blog reading of international material and often miss out on local news.  Flash is an excellent way of keeping up with local happenings. If you don't get the flash, then  give it a try for a while.  I'm sure you will find it as useful as I do.
 
DotNetNuke 4
I had a go at installing DNN 4 and actually got it working on the second attempt.  On the first attempt it seemed to work fine, but it wouldn't stop installing.  Normally the installer creates a dnn.config file in the install folder that contains the currently installed version.  This file is used instead of querying the database on each request. However, this file wasn't created for me because the  default installation doesn't include the correct settings in the web.config (UseDNNConfig=true).  I turned this on, after I installed, but by then I think it was too late. So, I deleted the database and ran up the site again.  This time, it created the dnn.config file and everything works sweetly.
 
The old DNN 2.1.2 NZ .Net skin uploaded to the new DNN 4 site without complaint and it actually looks just the same as the old site.  This will save me considerable hassle when I do the upgrade.
 
I also created the ASP.Net membership/roles/profile database separately in the hope that I'll be able to share this DB with community server. That's my next task.
 
There's still a number of 3rd party components that I need to replace or upgrade.  There's really only one that I need upgraded ASAP so I better start nagging the vendor or figuring out how to replace it.
 
Ruby on Rails
I met a chap on Friday (whilst attending an all-day stag party - lots of games - no strippers or pranks) who is using Ruby on Rails for a couple of projects.  "You lucky bastard" I said. I love bleeding edge and Ruby on Rails is about as bloody as you will get at the moment. If you don't know anything about Ruby or Rails or Ruby on Rails, then check out the web site. 
 
Anyways, I'd been looking for a suitable candidate for a head-to-head challenge for a user group session and ASP.Net v Ruby on Rails sounds like the perfect solution.  From everything I've heard about Ruby and Rails, this could be a very interesting contest. Stay tuned in the new year.
 
Windows MCE
I've had a loan Media Centre PC for a few months now and I've been doing some testing with it.  MCE does offer some nice features over standard Windows XP that make it work well on a TV screen, but overall.. how can I put this gently? - I think it sucks.  I know some people love it and it does certainly try to be a TV/DVD/Video/PVR replacement but, for me, it just doesn't fly.  Why?
  1. There are no out-of-the-box channel guides for New Zealand.  I tried to get XMLTV to work with it - thanks Nic - but I failed.  With more effort I'm sure I could have got it to work.
  2. All the functions of MCE are poor cousins to the full PC equivalents.
  3. The quality of TV cards pictures is not as good as real TV.
  4. You can't rip music or video to the hard drive.
  5. It's hard to manage folders for large picture, movie and music libraries.
To make MCE truly useful requires quite a few hacks and a lot of switching back to native Windows.  I could live with all these short comings if I wanted to come home from a hard day in front of a PC and have a hard night in front of the TV, but I'm not and this is my point -  Television is an alternative to a brain.  If I have to think about how to watch TV, then it's NOT TV anymore. To me, MCE seems like a great way of making a simple device that works into a complex one that doesn't.
 
 
Sunday, December 18, 2005 9:43:25 PM (New Zealand Daylight Time, UTC+13:00)  #    Comments [1]   General  | 
# Friday, December 16, 2005
I'm very pleased to announce the .Net User Groups have started up a new mailling list for the discussion of all aspects of Team System - including Team Suite, Team Foundation Server, Team Build, Team Test, Reporting, Process Guidance, Portal, Licensing, etc etc etc.  This list is intended to be used primarily for Kiwi's and local New Zealand issues but anyone is welcome to join.
 
Hopefully this forum will promote some lively discussions and provide some support for users new and old.
 
You can subscribe to the list here.
Friday, December 16, 2005 8:40:11 AM (New Zealand Daylight Time, UTC+13:00)  #    Comments [0]   General | Team System  | 
# Friday, December 09, 2005
I've been playing with Testing in Team System this week (Wow!  I want to be a tester!  But that's another story for a later date).  I am creating a sequence of manual tests for UAT (we don't have any UI Testing tools) and I want the testers/users to start with a clean build of the system and database with each test run. 
 
Using RedGate SQL Packager I created a script to create the database with some sample starting data. I added a couple of tasks to my Team Build to create a database and execute the script on it.  Using my custom ExecuteSQL task I added the following:

<TestDBServer>fred</TestDBServer>
<
TestDBName>$(BuildNumber)</TestDBName
>
<
TestDBCreateConnectionString>
 data source=$(TestDBServer);integrated security=SSPI;Pooling=true
</TestDBCreateConnectionString>

<Message Text="Creating test database " Importance="normal"/>
<
ExecuteSQL ConnectionString="$(TestDBCreateConnectionString)"
   
Command="create database [$(BuildNumber)]" />

This created an empty database with a name of whatever the BuildNumber is.  Note the [ and ] around the $(BuildNumber). 

Next, I execute the script to create the database objects and populate it with sample data:

<Exec Command="isql.exe -E -S $(TestDBServer) -i $(BuildDirectoryPath)\SUMS3\SUMS3Debug\Sources\Airways.SUMS3\CreateTestDB.SQL -d [$(BuildNumber)]" />

The SQL script is checked in with the solution files, hence the funcky path to it.  I could have had it in the Team Build project folder, but it's more visible in the solution.

So, now my Team Build produces completely isolated instances.  Users can happily compare old versions with the latest and greatest version. 

Friday, December 09, 2005 4:28:39 PM (New Zealand Daylight Time, UTC+13:00)  #    Comments [0]   Team System | Visual Studio  | 
# Monday, December 05, 2005
I just spotted something on MSDN about InfoCard and not knowing what the heck it was I searched and found a good description of it. Now I get an idea of what it is and it sounds like a good idea, but really, something that uses twelve-ish WS* standards seems way to much like something you'd get from IBM! 
 
  • SOAP
  • WS-Addressing
  • WS-MetadataExchange
  • WS-Policy
  • WS-Security
  • WS-SecurityPolicy
  • WS-Transfer
  • WS-Trust
  • XML Signature
  • XML Encryption
  • SAML
  • WS-Federation (unclear)
  •  
    Phew!

    Monday, December 05, 2005 4:34:27 PM (New Zealand Daylight Time, UTC+13:00)  #    Comments [0]   General  | 
    Here's a great resource posted by Rob Caron : Visual Studio Team System TechNotes.  It's a great collection of notes on various aspect to VSTS.  It's great having all this in one place.  Well done guys!
    Monday, December 05, 2005 10:52:28 AM (New Zealand Daylight Time, UTC+13:00)  #    Comments [3]   Team System  | 
    # Friday, December 02, 2005
    I have my Team Builds being published to a Sharepoint List and this works very well, but by default it's hard for the users to find the list.  The default template for the project portal does not have a spare zone for me to drop the list into; instead, users have to navigate through the "Documents & Lists" page.
     
    Thankfully, customising the project portal page is VERY easy thanks to the integration with Frontpage 2003.  When you have this installed, you get an Edit option in IE.  Clicking this will launch the site in Frontpage and you can add a Web Part Zone very easily.
     
    I added a new zone to the top of the home page and them dropped my list in there, along with some instructions for users.  Here's what it looks like:
     
     
    Next?  Well now it gets harder.  It'd like to :
    1. Display a list of Work Items for the project and let users drill down to the details.
    2. Let user create new work items.
    3. Display a project summary WITHOUT using the icky reporting UI.  This will probably include remaining work, velocity and issues in a composite report.
    To do the above I need to delve into the TFS API and learn how to create Web Parts so this may take a while.  Or not... we'll see.
    Friday, December 02, 2005 8:56:02 AM (New Zealand Daylight Time, UTC+13:00)  #    Comments [0]   Team System  | 
    # Thursday, December 01, 2005
    There's a bug in Crystal for Visual Studio 2005 (surprise surprise!) when you have a stored procedure in your report WITH parameters AND you change the database connection at runtime.  Basically, no matter what you do, it will tell you that the parameter has not been specified, when you know darn well that it has!
     
    I found a discussion and the solution hereWish I was using SQL Reporting :{
    Thursday, December 01, 2005 11:45:12 AM (New Zealand Daylight Time, UTC+13:00)  #    Comments [2]   General | Visual Studio  | 
    # Wednesday, November 30, 2005
    There's a bug in TFS Beta 3 that stops the Analysis Services updating the cubes for reports.  Apparently this is something to do with locales and date/time formats.  The fix is pretty simple.  See http://forums.microsoft.com/msdn/ShowPost.aspx?PostID=103529 for a discussion and the solution.
    Wednesday, November 30, 2005 10:05:38 AM (New Zealand Daylight Time, UTC+13:00)  #    Comments [0]   Team System  | 
    # Tuesday, November 29, 2005
    When my Team Build succeeds, it uses a custom task to publish a build so that users (testers) can execute the WinForms client.  This is presented to users in a single page web app that looks like this:
     
     
    I did this for my 2003/1.1 apps and it works well.  Using it for the 2005/2.0 apps seems logical and easy.  However, as Team System creates a SharePoint site for each project it seemed more logical to publish the deployed builds there. So, that's what I did.  I need to document this more thoroughly but I wanted to get this down before it's spilled over the edge.

    Windows SharePoint Services (WSS) Joy

    Firstly, I created a new List in the SharePoint site and called this "Deployed Builds".  It looks like this:
     
    Next, I created a small prototype console app to test creating items in the SharePoint list.  This was fun, NOT!  I had a couple of issues and teething problems:
    1. You would think you need an SDK for doing WSS programming.  When you look at the WSS Site you find a link to download the WSS SDK sure enough but you will also notice the "Sharepoint Products & Technologies SDK" which is a separate download.
    2. Both the SDK's are just help files - there is no libraries.  To get Microsoft.SharePoint.dll - the .Net API - you need to download and install the Web Part Templates for Visual Studio.
    3. Depending on what you want to do, you probably don't need this either.  You can use the web services directly, which is what I did.
    4. You will still need the WSSSDK though as it documents the web service API, CAML and related structures.
    So, after a couple of hours of stuffing around, I had something that ran but produced the dreaded "Cannot complete action - Please Try Again" error.  This is a catch-all for a lot of errors in WSS.  After much reading and cursing and stomping of the keyboard, I found a blog entry that told me exactly what the problem was.  When you insert a URL field, you need to format it correctly as "url, description".
     

    MSBuild WSS Task

    Now I had the prototype working, I converted this to a MSBuild Task. I wanted the task to be generic so I could use it to populate any SharePoint list.  To use the task, you do something like this. 
     
    Firstly create a list of name/value pairs that match the SharePoint list:
     
      <ItemGroup>
        <PortalListValues Include="URL">
          <FieldName>URL</FieldName>
          <FieldValue>file://$(ClientDeployDest)\airways.sums.exe, SUMS III</FieldValue>     
        </PortalListValues>
        <PortalListValues Include="Location">
          <FieldName>Location</FieldName>
          <FieldValue>TPK</FieldValue>
        </PortalListValues>
      </ItemGroup>
     
    In my case, I'm leaving the Note field blank and the Active field will default to "No".  Notice that the URL is a file location and that the description is included.
     
    Next, I call the task thus:
     
    <UsingTask TaskName="Airways.Build.Tasks.WSS.AddListItem" AssemblyFile="Airways.Build.Tasks.dll"/>
     
    ...
     
    <Target Name="AfterDropBuild">

      <AddListItem SiteURL="
    http://myserver/sites/sums3
        ListName="Deployed Builds"
        FieldValues="@(PortalListValues)" />
    </Target>
     

    Viewing the List

    When an item is added to the WSS list the Active field defaults to "No".  The default view in SharePoint excludes records that are not active.  I have another personal view that I use to edit the records and activate them for users.  This way I can build as often as I like and "release" when I'm ready.

    Tuesday, November 29, 2005 4:30:54 PM (New Zealand Daylight Time, UTC+13:00)  #    Comments [1]   Team System  | 
    # Thursday, November 24, 2005
    I think this is a new feature, please tell me if it's not so I can kick myself.
     
    When an exception occurs deep in some code, the reason is most likely at a much higher level, e.g.:
     
    This exception occurred in DataSet code due to something wacky in the UI.  The call stack shows how we got here:
     
    It's very easy to navigate back through the call stack and examine variable values etc, but often you have to restart the app with a break point set in a suitable place - at least that's what I thought till I noticed this:
     
     
    When you select this it unwinds the execution of your application back to the selected Frame in the call stack.  How cool is that ?  Very cool I think.
    Thursday, November 24, 2005 3:27:03 PM (New Zealand Daylight Time, UTC+13:00)  #    Comments [0]   Visual Studio  | 
    # Monday, November 21, 2005
    I've just added one more task to my Team Build and its done - for now.  Here's how the whole thing works.
    1. I execute a Team Build manually.
    2. When the project builds successfully, it copies the client and server outputs to a publically visible path.
    3. The build configures the web service virtual directory.
    4. The build updates the client .config to point to the new web service vdir.
    5. The build writes a record to a SQL table.
    6. Team build sends me an email alert to tell me the build completed successfully.
    7. I manaually edit the log table to release the build and enter a note.
    8. The user accesses the launch page and views the build details.
    9. The user launches a build for testing via a link on the launch page.
    10. I go home happy.
    The last custom task I added was a SQL Command executor which I use for logging the successfull deployment.  The launch page uses this to display a menu of successful builds.  The application is launched from a UNC path so users need to configure some machine security settings, for which I provide an MSI.
     
    Now back to finishing the (never ending) project.
    Monday, November 21, 2005 2:45:23 PM (New Zealand Daylight Time, UTC+13:00)  #    Comments [3]   Team System  | 
    The next step of my project deployment via Team Build is to update the exe.config file for the newly created web service.  To do this, I needed to create a task to edit an XML file.  Once again I looked at the SDC tasks, but found that it was easier to write my own.  I added the following to the build file.
    <PropertyGroup>
       ...
      <TestDataUrl>http://blah/SUMSWS $(BuildNumber)/SUMSDataasmx</TestDataUrl>
      <TestSecurityUrl>http://blah/SUMSWS $(BuildNumber)/SUMSSecurity.asmx</TestSecurityUrl>
    </PropertyGroup>
    <UsingTask TaskName="AirwaysBuild.Tasks.XMLFile.ModifyXMLNode" AssemblyFile="Airways.Build.Tasks.dll"/>
    <Target Name="AfterDropBuild">
      ... 
      <!-- update the app.config -->
      <ModifyXMLNode
        Filename="$(ClientDeployDest)\Airways.SUMS.exe.config"
        XPath="/configuration/applicationSettings/Airways.SUMS.Properties.Settings/setting[@name='WSDataURL']/value"
        NewValue="$(TestDataUrl)"
      />
      <ModifyXMLNode
        Filename="$(ClientDeployDest)\Airways.SUMS.exe.config"
        XPath="/configuration/applicationSettings/Airways.SUMS.Properties.Settings/setting[@name='WSSecurityURL']/value"
        NewValue="$(TestSecurityUrl)"
      />
      <ModifyXMLNode
        Filename="$(ClientDeployDest)\Airways.SUMS.exe.config"
        XPath="/configuration/applicationSettings/Airways.SUMS.Properties.Settings/setting[@name='BuildVersion']/value"
        NewValue="$(BuildNumber)"
      />

    </Target>
     
    The two new properties define the ASMX urls for the two services.  In the AfterDropBuild target I use these to update the exe.config file.  A third task updates a BuildVersion setting in the config which is displayed on the applications main window caption (so the user can clearly see which build they are running).
     
    Each ModifyXMLNode task on the target defines the file name to modify, an XPath statement for the element or attribute and the new value to insert.  The new values are treated as text / strings and I use these in the task code thus:
    XmlNode node = Document.DocumentElement.SelectSingleNode(XPath);
    if (node != null)
    {
      node.InnerText = NewValue;
    }
    I'm not sure if I should use InnerXml instead of InnerText - what I have now works well enough.
     
    Once again, if you'd like the code for this task, shoot me an email or use the contact link on this blog or post a comment.  I'll probably be adding more tasks sooner or later.  When I get a bigger library of useful tasks I'll post it for download somewhere.
     
    I must say that creating tasks for MSBuild is a lot of fun.  I'd be happy doing this all day every day.  You get to play with lots of different stuff, you don't have to create fancy UI and it's really very easy to do.  Back in NAnt days I never created a task - probably because there is already a vast library of free ones available, but also because I thought it was harder to do. 
    Monday, November 21, 2005 9:53:52 AM (New Zealand Daylight Time, UTC+13:00)  #    Comments [1]   Team System  | 
    # Friday, November 18, 2005
    All my research and experimentation is starting to pay dividends.  I've managed to extend my Team Build to copy the project outputs from the drop location to a new folder structure and create an IIS virtual directory for the web service. 
     
    So far, this is the steps I followed. 
     
    Edit the TFSBuild.proj file
    I added the following to the build:
     
      <PropertyGroup>
        <ClientDeploySource>$(DropLocation)\$(BuildNumber)\Debug</ClientDeploySource>
        <ServerDeploySource>$(DropLocation)\$(BuildNumber)\Debug\ PublishedWebsites\SUMSWS</ServerDeploySource>
        <ClientDeployDest>$(DropLocation)\test $(BuildNumber)</ClientDeployDest>
        <ServerDeployDest>$(DropLocation)\test $(BuildNumber)\SUMSWS</ServerDeployDest>
        <ServerLocalPath>D:\devweb\deployment\SUMS3\test $(BuildNumber)\SUMSWS</ServerLocalPath>

      </PropertyGroup>
      <UsingTask TaskName="Airways.Build.Tasks.IIS.CreateVDir" AssemblyFile="Airways.Build.Tasks.dll"/>
      <Target Name="AfterDropBuild">
        <CreateItem Include="$(ClientDeploySource)\*.dll">
          <Output TaskParameter="Include" ItemName="ClientDLLs"/>     
        </CreateItem>
        <CreateItem Include="$(ClientDeploySource)\*.exe">
          <Output TaskParameter="Include" ItemName="ClientEXEs"/>
        </CreateItem>
        <CreateItem Include="$(ClientDeploySource)\*.exe.config">
          <Output TaskParameter="Include" ItemName="ClientCONFIGs"/>
        </CreateItem>
        <CreateItem Include="$(ServerDeploySource)\**\*.*">
          <Output TaskParameter="Include" ItemName="ServiceFiles"/>
        </CreateItem>
        <!-- copy the client filed -->
        <Copy SourceFiles="@(ClientDLLs)" DestinationFolder="$(ClientDeployDest)" />
        <Copy SourceFiles="@(ClientEXEs)" DestinationFolder="$(ClientDeployDest)" />
        <Copy SourceFiles="@(ClientCONFIGs)" DestinationFolder="$(ClientDeployDest)" />
        <!-- copy the web service -->
        <Copy SourceFiles="@(ServiceFiles)" DestinationFiles="@(ServiceFiles->'$(ServerDeployDest)\%(RecursiveDir)%(Filename)%(Extension)')" />
       
        <!-- make the virtual dir -->
        <CreateVDir Server="localhost" Site="BSDTesting" PhysicalPath="$(ServerLocalPath)" VirtualPath="SUMSWS $(BuildNumber)" />
        <!-- create the test db ?? -->
        <!-- update the .config -->
        <!-- update the launcher XML file -->
       
      </Target>
    The property group defines some source and destination folders.  These are based on the DropLocation which is defined at the top of the build file.  The destination folders for the client and server happen to be on the same machine to keep things simple, but these could (and probably should) be on another server.
     
    Next, there is a new custom task I made for creating a virtual directory in IIS.  I search for a while without luck to find a built in solution for this or someone else's solution but in the end it was very easy and fun to create my own task.  My first attempt actually worked on the first execution!  Its not a very complete task - you can't do everything you might want to do with a VDIR but for me it's adequate.  If you want the code then shoot me an email or post a comment.  I had a look at .NET Solution Build, Deployment, Process & Tools but I found this too confusing at the time and thought it was easier and more enjoyable to create my own task.  Now I understand the process better I might take another look at this handy kit.
     
    Next in the build file is a new Target.  This overrides the default AfterDropBuild target.  We need to use CreateItem as the items to be copied are produced by previous targets and don't exist when the build file is loaded.  If I had specified all the actual files by name rather than wildcard then I could have used an ItemGroup, but that would be tedious and error prone. The rest of the target is pretty self explanatory.
     
    Checkin the TFSBuild and Custom Task
    Once I made the changes I checked in the TFSBuild file and added the custom  task dll to the Team Build folder in Source Control.  When the Team Build executes, these files extracted to the build server so it's not necessary to put the custom task in the build server GAC or any such horrid stuff.
     
     
    I've still a few more steps to complete before I can have new builds automatically published to users/testers but hopefully this will be as easy and fun as the rest of this.  I'll post an update when I've got the whole thing working.
    Friday, November 18, 2005 12:18:15 PM (New Zealand Daylight Time, UTC+13:00)  #    Comments [2]   Team System  | 
    Copyright © 2012 Peter G Jones. All rights reserved.
    DasBlog 'Portal' theme by Johnny Hughes.
    Pick a theme: