Thursday, March 12, 2009
On the road at the min with work so that's why I haven't been blogging techie stuff recently. I'm enjoying Nebraska but I've found my ideal ride home, it can do New York to London in 1 hour 55 minutes.



I've been working with a friend on a site for the NWMTUG we're hoping to have loads of war stories to share about this we're using GIT and the ASP.Net MVC framework and some other cool stuff.
posted on Thursday, March 12, 2009 4:04:41 AM (GMT Standard Time, UTC+00:00)  #    Add Comment | Comments [3]
 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]