Blog Home  Home Feed your aggregator (RSS 2.0)  
.Net Jonesie - More Team Build Goodness - SharePoint lists
A simple programmers blog
 
# 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  | 
Wednesday, November 30, 2005 7:58:45 PM (New Zealand Daylight Time, UTC+13:00)
Wow, that's a pretty nifty task! Nice to see another one to add to the list of cool things people have built to customise MSBuild to their needs.

Neil
Comments are closed.
Copyright © 2012 Peter G Jones. All rights reserved.
DasBlog 'Portal' theme by Johnny Hughes.
Pick a theme: