Thursday, February 26, 2009
The Northwest Microsoft Technology User Group will be holding its first session on Tuesday 7th April at 7:00 pm in the MS Building of the University of Ulster's Magee campus. The building and adjacent car park is marked on the map below.

The session will be "Best Practice for getting a business to adopt SharePoint from day 1" and will be presented by Ciaran Colgan.


View Larger Map
posted on Thursday, February 26, 2009 11:41:00 PM (GMT Standard Time, UTC+00:00)  #    Add Comment | Comments [0]
 Tuesday, February 24, 2009
When reading "The Productive Programmer" one of the things that really impressed me was the ability to  write an ant build script using groovy. Currently make Java days seem to be more and more on ice as I travel further down the road of .NET I wanted this ability when generating build scripts for my .Net  
solutions. Searching the web lead me to psake. This is a project that allows you to use PowerShell syntax in your build scripts.

Psake was started by James Kovacs and is in the early stages of development. You can download the source  (a single Ps1 file) from Google code using the following address svn url:

    http://psake.googlecode.com/svn/trunk/ psake-read-only

On windows I would recommend Tortoise SVN. Once you checkout the project you will get have a single ps1 file called "psake.ps1" and two folders "examples" and "images". The examples folder contains some useful examples on using psake.

The basic usage of psake is:

psake buildFile

Where buildFile is a PowerShell script file that contains the build tasks. If no build file is specified  
psake will assume default.ps1. For additional information on using psake from the command line use psake -help.

Psake is a wrapper around PowerShell that adds functionality specific for creating a build script. Because  it has been built on top of PowerShell anything you can do in PowerShell is available to you in psake. One  other useful point to mention is that psake will automatically add the correct version of the .NET  framework to its path thus calling framework tools like msbuild.exe, csc.exe or vbc.exe extremely straight forward.

An example build script that is included with the download is:

properties {
  $testMessage = 'Executed Test!'
  $compileMessage = 'Executed Compile!'
  $cleanMessage = 'Executed Clean!'
}

task default -depends Test

task Test -depends Compile, Clean {
  Write-Host $testMessage
}

task Compile -depends Clean {
  Write-Host $compileMessage
}

task Clean {
  Write-Host $cleanMessage
}



The default entry point for your script is the default task defined as:

task default

You then specify what tasks the default task depends on using the '-depends' switch. So in the build  script above the default task depends on the Test task the test task depends on the Compile and Clean tasks, therefore unsurprisingly the clean task will execute followed by the compile and finally the script  in the Test task will execute.


Here is s simple example that builds a Hello World solution:


task default -depends Build

task Build
-depends Clean{
  msbuild "C:\Users\Alan\Code\PowerShell\psake\HelloWorld\HelloWorld.sln"
}

task Clean {
  msbuild
"C:\Users\Alan\Code\PowerShell\psake\HelloWorld\HelloWorld.sln" /t:clean
}



This is a very simple script that cleans and builds a solution using MsBuild. The screenshot below shows the output from executing the script, you can see that it reports the task that it is executing and displays a green success message. If the task fails a red error message is displayed detailing why the task failed.




Although this is still a work in progress I think this project definitely has potential as script such as  that shown above can be much cleaner and hence easier to read than XML therefore this is a project I would hotly tip for the future.

Some useful resources, I recommend the podcast from PowerScripting as this is an interview with James Kovacs where he really explains the pros of psake:


posted on Tuesday, February 24, 2009 9:18:45 PM (GMT Standard Time, UTC+00:00)  #    Add Comment | Comments [0]
 Thursday, February 19, 2009
Nikhil Kothari a software architect on Microsoft's .NET Developer Platform group has created a free tool called Script# that allows you write C# code that will be compiled into JavaScript. Using Script# you can take advantage of all your existing .NET tools and the power of Visual Studio. According to nikhil's own site Script# is used extensively within Microsoft when building Ajax experiences in Windows Live and Office along with external companies such as Facebook.

The Script# web site is http://projects.nikhilk.net/ScriptSharp, you can download Script# for Visual Studio 2005 or 2008. Along with the plug-ins for Visual Studio there is a very good PDF Readme that contains lots of examples of using Script#.

Nikhi also has a roadmap for Script# two notable additions are planned for 2009 Unit testing support and jQuery support. This is something I'm playing with and I think is worth checking out.

posted on Thursday, February 19, 2009 11:46:27 PM (GMT Standard Time, UTC+00:00)  #    Add Comment | Comments [0]
 Tuesday, February 17, 2009
With the advent of Windows PowerShell automating tasks in windows should now be a sinch for a .NET developer as PowerShell's scripting language is relatively easy to a C# programmer to pickup (trust me I've come down the path). One of the things I have a lot of is MP3 files from my extensive music collection and various podcats that I listen to, so I needed a way to manipulate these tags for example change some details such as adding missing information or even move the files into my music folderr structure.

A library that allowed me to do this easily was TagLib Sharp. It's avaliable from Novell and will work with .NET and Mono.

Because this is a .NET assembly you are free to use it in your C#, Visual Basic .NET. To use the library with any of thse languages simply add the assembly as a reference to your project and add the appropriate using or imports statement to the top of the class file that will use the library. However as PowerShell is my new best friend I'll show you how to use the library with PowerShell.

To use any assembly in your PowerShell script you can use the Assembly class in the System.Reflection namespace. The Assembly classes has the static LoadFile method that allows you to specify a location to load a dll from.

[Reflection.Assembly]::LoadFile("C:\Users\Alan\Code\PowerShell\MyScripts\taglib-sharp-dotnet20.dll")


Once you have imported the assembly as shown above you can begin to use it to modify settings on you media files. For example the line below will create a File object that represents the specified physical media file.

$media = [TagLib.File]::Create( "$filePath" )

Once this has been done you simply access the various tags using $media.Tag.XXX. The script below will set the Title and Track information.

$media.Tag.Title = $matches["title"]
$media.Tag.Track = $trackNum.ToString()

Once you have set the tags to the values you want you save the changes by calling the Save method on the media file object.

$media.Save()

One thing I did notice when using this library was that it failed to set the tags if they previously had no value so to get around this I manually set the tags to a character for sting values and 1 for numberic values suchas year and track number.




posted on Tuesday, February 17, 2009 3:16:51 PM (GMT Standard Time, UTC+00:00)  #    Add Comment | Comments [0]
 Sunday, February 15, 2009
This is one of the books from Manning with the cool covers that I like. This book has been written by Bruce Payette one of the designers of PowerShell. Because of this the book offers in-depth information on many aspects of PowerShell.  The book is split into two sections. Part one focuses on the basics, it covers using PowerShell at the command line and writing and run your own scripts. I read the nine chapters in this section from start to finish and was please to find lots of working and easy to follow code examples which I could play with and easily refer back to as I wrote my own scripts. I found this section greatly enhanced my knowledge of PowerShell in a short space of time, I would put this down to a good balance between verbose text and script examples to experiment with and if you are like me and learn beat by doing this book will suit you. The second section covered more advanced topics such as:
  1. Processing text files and XML
  2. .NET and WinForms
  3. Windows objects: COM and WMI
  4. Security

These were also detailed chapters with good examples however to date I have gotten more use from chapters 10 and 11 this is no fault  with the book it’s more of a reflection on what I’ve been working with recently. Since taking the time to sit down with this book I have become very keen on PowerShell especially having seen and used the scripting tools available on Linux and UNIX.

I found the book well structured and importantly for me it contains lots of script examples. Previously I had tried to learn PowerShell simply from various web sites however lack of discipline kept getting in the way. With the book I was able to discipline myself better and managed to work through this book in just over one week. Now I’m able to write my own scripts and when I’ve needed to I’ve found it very easy to refer back to the book. The back cover says that this is a book for sysadmins and developers, I would agree with this and would recommend this book for people with previous scripting of programming experience if you don’t have these then a more basic beginners book may allow you to make more progress.

The books web site: http://www.manning.com/payette/

posted on Sunday, February 15, 2009 6:18:46 PM (GMT Standard Time, UTC+00:00)  #    Add Comment | Comments [0]
 Thursday, February 12, 2009
If you are writing any scripts for PowerShell I'd recommend looking at PowerGUI Script Editor. It's a free comunity project that has some really nice features you now expect when writting code such as intelli-sense, syntax highlighting and the ability to debug your script.

The overall aim of the project is to create a GUI for Windows PowerShell where you can manipulate objects in PowerShell by pointing and clicking. For example there is bundled functionality to list all process running on the current system invoke actions on these processes such as stopping the process. Personally I just use the script editor to edit my scripts and as I have customized my PowerShell as described in a previous post, it easy for me to then execute these scripts as I need.




posted on Thursday, February 12, 2009 2:26:33 PM (GMT Standard Time, UTC+00:00)  #    Add Comment | Comments [0]
 Wednesday, February 11, 2009
Like alot of people my maths was stronger than my english at High School, probably one of the reason I was attracted to computer programming in the first place. Even today one of my weaker points would be spelling. If you're like me fear not help is at hand from ComponentOne with IntelliSpell.

IntelliSpell is an addon for Visual Studio 2008 or 2005 that will spell check your comments, strings, HTML, XML resources and general text. There is a free community edition and a Professional edition at $79.99 which offers a few more features. You get a comparison of the two editions along with download and purchase links at: http://www.componentone.com/SuperProducts/IntelliSpell/

Once you have installed IntelliSpell the spellchecker is avaliable from Visual Studio's tools menu as shown in the screenshot. With the Professional edition you get the ability to spell check an entier solution at once along with 'as-you-type spell-checking', but with the community edtion you spell check one file at time, still better than we had before. Any spelling mistakes will be shown in the task list.






The task list showing the spelling mistakes in the current document:





The IntelliSpell window that allows you to move from spelling mistake to spelling mistake and correct them as you go.




posted on Wednesday, February 11, 2009 3:12:35 PM (GMT Standard Time, UTC+00:00)  #    Add Comment | Comments [1]
 Monday, February 09, 2009
Most of you probably have heard of, or even used Camtasia, it's a wonderful product with many nice features. I really liked how the camera would automatically zoom in and out as I entered text in a web form. However no matter how nice Camtasia Studio is, it's well out of my price range for all the uasge I would make of it. However I've just found an alternative in the form on CamStudio.

It's a open source implementation of a screen recorder that includes some nice features such as defining an area of the screen which the camera should stay focused on. Most importantly to me is the ability to convert the AVI captured video to a SWF that can then be embedded in a web page. This is the tool I used for my previous post on Windows Mobile Internet Connection sharing.

posted on Monday, February 09, 2009 3:11:55 PM (GMT Standard Time, UTC+00:00)  #    Add Comment | Comments [0]
 Sunday, February 08, 2009
Developer, Developer, Developer (DDD) are free community events held across the and Ireland which highlight some interesting technologies in the field of .NET. Last year the event as in Galway this year it will be in Belfast on Saturday 4th April.

Having attended last years event I can recommend this as very worth while. You can get more details at the confrences web site. The event will be held at the Belfast Metropolitan College on Brunswick Street Building, Belfast.





posted on Sunday, February 08, 2009 9:52:37 AM (GMT Standard Time, UTC+00:00)  #    Add Comment | Comments [0]
 Friday, February 06, 2009
Windows PowerShell is Microsoft's latest command line and scripting language. It's a major move forward from the days on MS-DOS Batch files and gives Windows a scripting environment more in keeping with the likes of the Bash Shell on Linux. Needless to say I like PowerShell and there are enough people out there already singing it's prasies what I want to highlight is the ability to customize the PowerShell environment for yourself.

Those of you comming from Unix or Linux will possibly have at one point encountered the '.bash_profile'. This was a hidden file in the root of your home directory and allowed you to customize various settings suchas adding environment variables. This was extremely useful and I can recall adding various JAR files to a classpath environment variable in a previous life. So when I came over to PowerShell and started writting my own scripts I wanted to may life easy for myself. Typing C:\users\alan\code\scripts is just too much like hard word even with tab complition. Wouldn't it be nice to just type 'cd $MyScripts'? Well it is and with tab completion of environment variables all I need to type is 'cd $mys' the tab key takes care of the rest.

PowerSehll has a hierarchl structure for profiles which allows profiles to be specified once for all users or for an individual user. It's simply a matter of knowing where on the hard drive to store the 'ps1' script. Your options are as follows:
  • %windir%\system32\WindowsPowerShell\v1.0\profile.ps1
  • %windir%\system32\WindowsPowerShell\v1.0\ Microsoft.PowerShell_profile.ps1
  • %UserProfile%\My Documents\WindowsPowerShell\profile.ps1
  • %UserProfile%\My Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1

Those profiles stored under the %windir% will effect all users whereas profiles stored under the %UserProfile% will effect only that user.

Ok so now we can look at a bit of PowerShell script to create the profile and begin customizing it.


test-path $profile
new-item -path $profile -itemtype file -force
notepad $profile

Note if you wanted to create a profile for all users replace the '-path' argument on the new-item cmdlet call with one of the paths listed above.

Now that you have a profile you can start customizing it, one of the most common things I've stored in my profile in the past has been environment variables. To do this with PowerShell simply use the Set-Variable cmdlet as shown below where I create a new variable called 'MyScripts' which will point to 'C:\Users\Alan\Code\PowerShell\MyScripts'


Set-Variable -Name MyScripts -Value "C:\Users\Alan\Code\PowerShell\MyScripts"

posted on Friday, February 06, 2009 4:14:24 PM (GMT Standard Time, UTC+00:00)  #    Add Comment | Comments [0]
 Thursday, February 05, 2009
If you've used the Command Prompt Here PowerToy in the past you'll definitely want this ability when you make the move to PowerShell. You have two options.

  1. Customize the ini file for the command prompt here PowerToy
  2. Download an already had version here from Scott Hansleman

posted on Thursday, February 05, 2009 4:45:34 PM (GMT Standard Time, UTC+00:00)  #    Add Comment | Comments [0]
 Wednesday, February 04, 2009
Microsoft Press's Professional Series (the silver ones :-)) aim to create a series of books that provide information for IT professionals in a technology independent manner. Examples of previous books in the series that I've enjoyed are Code complete by Steve McConnell and the Object Thinking by David West. Both of these contain information that can be easily transferred from one language to another such as between Java and C#.

Simple Architecture for Complex Enterprises by Roger Sessions sets out to create another book in this series; this time focusing on enterprise architecture in particular the focus is on the idea of creating simple solutions. The Book is split into two sections, the first concentrates on the issues of complexity. It starts off by giving an overview of the current state of play in the field of enterprise architecture. Following on from the description on enterprise architecture Roger gives an overview of The Zachman Framework, The Open Group Architecture Framework (TOGAF) and The Federal Enterprise Architecture (FEA). He points out how these should not be seen as competing against each other and how they can in fact be used to complement each other.

Now we dive into the main target that this book is hoping to address with chapter 2 "A First Look at Complexity". Along with defining complexity Roger proposes a solution in the form of partitioning that can be used to break complex system down into manageable chunks. This idea is well illustrated with the use of a Rubik's cube and how a 4-by-4 cube has 7.4 x 1045 possible permutations, whereas a 2-by-2 cube has 'only' 3.7 x 106 permutations. There eight 2-by-2 cubes would only have 29.6 x 10 ^6 possibilities. So this example proves with undisputable numbers that splitting a complex problem into smaller simpler problems allows us to produce simpler solutions.

The second section of the book is "The Quest for Simplification" is where we find Roger's suggestions on how we can avoid complexity in our applications. The methodology that is proposed to control complexity is Simple Iterative Process. SIP describes the main approaches used for complexity control: partitioning, simplification and iterative delivery. After this chapter 6 shows us an example of a system gone badly wrong and illustrates how SIP could have helped this system. The system in question is the National Program for Information Technology (NPfIT) that the British government commissioned for the National Health Service (NHS), even if you have no interest in IT and pay taxes in the UK this chapter should be of interest due to the colossal money squandered on the project due to late delivery all of which can be attributed to a complex solution being implemented for a complex problem. The next chapter the looks at how we can start designing software to control the complexity problem using a technique called "Software Fortresses".

I liked this book particularly because it does what I think is important when writing on a topic such as enterprise architecture, it will help get you thinking! I would encourage developers, architects and CIO's to read this book and ensure they are aware of the danger of complexity entering their projects.

I would like to conclude this post by referring to thoughts from the book. To be a successful architect you must be passionate about simplicity, you must aim to make it your goal to deliver a simple solution for complex problems, anybody can develop a complex solution, it takes a great architect to take a complex problem and deliver a simple solution.


posted on Wednesday, February 04, 2009 9:51:00 PM (GMT Standard Time, UTC+00:00)  #    Add Comment | Comments [0]