Tuesday, 23 June 2009

Removing the Blue Box from SQL in Visual Studio

I would have thought this would be easier to find, but I had to spend a full 15 minutes looking for information on it.  If you want to remove the blue border from your SQL in visual studio, then to to Tools > Options > Environment > Fonts and Colors.  In Display items choose SQL DML Marker and change the colour from blue to whatever your background is.  I feel kind of stupid now, that should have been easier to find.

Monday, 22 June 2009

XBOX 360 As a Media Centre with the DNS-323

I love my DNS-323.  I have it setup with a terabyte drive mirrored to a second drive for redundancy.  It also lets me download and torrent without having to leave my PC on, which is the reason I got it.

Now I’ve got an XBOX 360, and the main reason I managed to convince my non-game playing wife to get it was that I convinced her that it would make a great media centre.  Lucky for me it worked out.

Wireless Without the Adapter

The first problem is wireless, I just couldn’t bring myself to spend $140 AU on the wireless adapter for the XBOX.  There are a few places you can get it cheaper, but I still couldn’t find it less than $80 AU and even then I’d have to order it from China.  The XBOX does have a LAN connection though, so instead of running a cable all the way from my study to my living room I created a bridge.  The easiest way to do this is to get a very cheap router that supports DD-WRT firmware.  I chose the ASUS W520-GC. 

This is the most basic router I could find, it cost a total of $40 because I wanted it straight away instead of ordering it for $30 and I can use it to connect any device to my wireless from my living room (well up to 4 devices anyway).

Plug it in, install DD-WRT (use the ASUS update tool that comes with the router, the web interface doesn’t like the .bin file, oh and rename the .bin file to .trx) and then follow the instructions on the DD-WRT wiki to setup your bridge.  Test it with a laptop as it’s much easier to test and then plug in your XBOX.  A few tests of the PC connection should work.


While the XBOX 360 does support uPnP, it has it’s own format basically requiring your protocol to announce that it is looking for the XBOX.  The DNS-323, as of Firmware 1.04 (current 1.06) does this, and very well.  I would recommend upgrading your DNS-323 anyway, the new firmware helps many of the features work better.  You can follow DLink’s instructions on upgrading, it’s pretty easy so I won’t repeat it here.

Once the upgrade is done, go to advanced and uPnP and enable uPnP.  Choose the root of your NAS (or where ever you store your media) and then refresh.  This tends to drop out about 2/3 of the way through if you have a medium to large collection, but it’s only the interface and the refresh will work eventually.


Give it an hour, go to your XBOX, choose Music and then you should see your DNS-323 as a source.  Choose some music and entertain away!  Some codec’s are not supported, xVID I think is one of them.  I just convert all my videos using MediaCoder, to a format that I can play.

Still not Perfect

It’s still not perfect, I find that sometimes during media playback the connection to my network is lost.  I quick Test Connection seems to fire it back up and my media starts going again, but I’m not sure why it drops out.  It could be my bridge or it could be my XBOX hibernating a service it might not think it’s using.  I’ll post on it when I figure it out.

One Click Deployment with Visual Studio, Web Deployment Project and Web Deployment Tool

One of the things I’m keen on getting setup is a great solution for one click deployment.  Lucky for me one of Microsoft’s new tools is the Web Deployment Tool, but as it’s very new information on or about it is very limited and it’s quite complicated to figure out.  Fortunately once you do figure it out, it’s remarkably easy to use, as long as you have a little server knowledge and know how to use IIS.

Visual Studio

I’m using Visual Studio 2008.  This is apparently a lot easier in VSTS 2010, but I’m not all that keen on getting the Beta to work on our production web site, so I’ll be sticking with 2008 for some time.  You don’t need to do anything in particular to Visual Studio however, just install it.

Web Deployment Project

This first came out for Visual Studio 2005 and is a great tool.  Scott Gu has the best tutorial I know of on how to use it, you can find that here.  It’s a tutorial for 2005, but it works just the same in 2008.

Web Deployment Tool

The only thing I can say about this is that it is very difficult to use.  Not because the tool is all that complicated, in fact it’s remarkably simple, but because there are so many uses for it and so little information yet.  In its defence, it’s a new tool and currently only in BETA so I shouldn’t complain.  It is, however, very useful once you understand how it can work for you.

What I did

Assuming you already have a project setup in Visual Studio 2008 (or 2005) this should be pretty easy.  Read Scott Gu’s tutorial first on Web Deployment Projects because I’m going to assume that you know a little about these first. 

1. Create a Web Deployment Project

Add a web deployment project to your project.  If you’re developing a web site, just right click the website and choose the Add Web Deployment Project option.  You’ll get a new project with no files and a default name of <YourWebSite>_deploy.

As you’ve ready through Scott Gu’s tutorial you’ll know a little about this file.  One of the things I find most useful about it is the ability to overwrite sections of your web.config during the build deployment.  You will need a config file for each section you want to replace, though I expect it’s uncommon for there to be more than 4-6 of these sections.  I created a subdirectory called config and stored all my config files in there naming them after the section they were replacing, I.E. ProdAppSettings.config.


You’ll notice I’ve got a ProductionLog4Net.config file.  This didn’t actually work and I couldn’t get the default tool to replace this for me, if anyone reading this knows how to get the WebDeploymentProject to replace log4Net config sections please let me know.

2. Setup the Web Deployment Tool

This is the hardest step, mostly due to lack of information on how this tool works and most importantly how it can be useful to deploy directly from visual studio.  Firstly you’ll need to download the latest version of the tool, I used the 1.0 RC.  You’ll need to install two copies of this, one on your local machine and one on the server you’re going to deploy to.  On your local, you can install as minimal as you like because all you really need is MSDEPLOY. 

On the remote machine, your deployment server (production or test or whatever you call it), you’re going to need to install everything.  You need the Remote Agent Service and the IIS 7.0 Deployment Handler. If you really want you could probably get away without the PowerShell Cmdlets or the UI module for IIS Manager, but I think you’ll find use for them at some point.


Once the install is done you’re going to need to start a couple of services


The Web Deployment Agent Service and the Web Management Service should enable you to deploy from a remote location.  Now it’s best to test this, on your local machine fire up the Msdeploy Command Console, if you’ve in stalled the Web Deployment Tool locally with defaults you’ll find it under IIS 7.0 Extensions in the Programs list.  All it is really is a command prompt pointing at the right directory, so if you can’t find it I’m sure you’ll figure something out.

3. MSDeploy – Confusing

So MSDeploy is a little confusing to start with, lots of options and not much documentation.  I’ve used it in a particular way, but you can use it in many many ways.  What is boils down to is a synchronisation tool that you can use to synchronise files between directories and web servers (which really are just virtual directories anyway).  Run it without any commands and it’ll give you the idea.

What I want is to synchronise my local output from my Web Deployment Project with my remote web server.  This is easy.

The command is:

msdeploy -verb:sync -source:iisApp=C:\MyDir\MySite -dest:iisApp=<Website>, computerName=<RemoteDeploymentServer>, username=<UserWithAccess>, password=<Password> -skip:objectName=dirPath,absolutePath=<DirectoryYouDontWantToSync>-skip:objectName=dirPath,absolutePath=<DirectoryYouDontWantToSync2>

The sync verb will tell the deployment tool to synchronise the local directory and the remote one.  The  source is your local directory, the destination is the IIS website on the remote server.  You can skip directories that you don’t wan to sync, otherwise those directories would be deleted during the sync.

At this point I’d try it with a test from the out put of your Web Deployment Project.  I didn’t run into any problems once I understood how it worked, however you might.  I imagine the most likely problem is going to be a firewall restriction, however if you don’t have that it should work.  If not let me know.

4. One Click Deployment

I don’t want to have to leave visual studio and run some silly script just to deploy my site.  I want to do it with one click, or even better, as part of my build!  Well the web deployment project is great for this.


Choose “Open Project File” and find at the end of the XML the AfterBuild section.  Then just create an Exec command and set the Command to your msbuild command created above.

<Target Name="AfterBuild">
   <Exec Command="msdeploy -verb:sync -source:iisApp=$(OutputPath) -dest:iisApp=MyWebSite,computerName=DeploymentServer,username=DeploymentUser,password=password -skip:objectName=dirPath,absolutePath=DynamicImages -skip:objectName=dirPath,absolutePath=DynamicDirectory" ContinueOnError="false">

$(OutputPath) is the output path of your Web Deployment Project.

5. Run it!

If everything went according to plan, when you build it will now deploy your project to your web server.  There are a few things you should finish off before you’re done though.

Firstly, I would only set the web deployment project to build when your are in release mode.


That way your debug build are not deployed anywhere.  You could also not build it at all so that deployment is only done when you build the deployment project specifically.

Also, every time you do a build it’s going to release all your source every time.  This is  because the output files for your project will be replaced every time with new versions.  Easy change really, just tell your web deployment project not to merge the output and you’ll be fine.

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <OutputPath>removed from paste</OutputPath>

It will still deploy your DLL files every time because they are built with every rebuild, but with shadow copy in IIS this is not an issue.


So I now have one click deployment to my remote web server, right from inside visual studio.  I suppose it’s a little dangerous because any developer can now deploy right into the live environment, but as this is a small company here there is little risk of that.  If you don’t like that idea, you can setup a staging environment where you do deploy to and use the Web Deployment Tool to allow on demand synchronisation between the staging environment and the live one.

Thursday, 11 June 2009

Installing CruiseControl.NET on IIS 7

Something I came across today that I thought might be useful for someone to know.  If you install CruiseControl.NET under IIS 7 you will likely get a 500 error when you open the dashboard for the first time something like this:

HTTP Error 500.23 - Internal Server Error

An ASP.NET setting has been detected that does not apply in Integrated managed pipeline mode.


This is because the managed pipeline needs to be reverted to classic rather than the default for IIS 7.  It’s easy to do, just right click the virtual directory, choose manage application and advanced settings.  Change the Application Pool from DefaultAppPool (or whatever else it is for your default website) to Classic .NET AppPool and you’ll be right as reign.

Tuesday, 9 June 2009

Small Company Issue Management

I’ve recently started work at a small company, it’s a different environment for sure having come from a very large company.  One of my first tasks is to help formalise their development processes and setup issue and source management.  This is something I’ve done before, but only with very large development teams, so it should be interesting.  I’ve had to review a large number of issue and source control management systems so I thought I might as well blog about them.

I reviewed everything from Microsoft’s own VSTS running on our own servers to the smallest remotely hosted environments.

Visual Studio Team System

This is a very large product, with a very large price tag.  At a mere $10 000 just for the server, it is a little hard to see how a small company without a massive code base is going to get much bang for buck.  If I were still in a large company with 20-30 different .NET projects, all of which are load tested and have complicated build configurations I can see how it might be useful and well worth the money, but for a small company I find it hard to see the benefit, for the price.

The other problem with VSTS is that it’s very hard to find information about it.  I spent the better part of a week researching into it and was unable to find a demonstration that didn’t require me to download several gigabytes and spends days setting up a server just to try it out.  I think Microsoft would find a lot more buy-in if they had a hosted service that people could use to test tools that are so complicated.


I’ve used JIRA before, and it’s pretty good.  A lot of people believe that it over-complicates things, and they’re right.  In my last role it was a fantastic tool, because we had a complicated environment and needed the power that came with the complexity, but here with only a few projects at a time the complication of the tool is just not necessary and would introduce an un-required amount of overhead.

As a plus though, Atlassian will host your JIRA, Confluence and SVN environment for you at a pinch for a very reasonable price.  If you have a larger company with a complex environment that requires something like JIRA, I would recommend it.

Hosted Issue Management

There are a lot of tools in the cloud that you can use to manage your issue tracking and source control.  A quick search will find them for you, but some of notoriety are:

And they’re all pretty good in their own way, though I’m not going to bother doing a matrix. In short the ones with * against them have SVN hosting as well, which is fantastic.  After going through each of them I discounted every one of them except Assembla and Unfuddle, disputably the most popular of the list.  Both have SVN hosting and a good issue management system.


Slightly cheaper that Unfuddle, the interface is a little more complicated and the tool provides a lot of agile functionality.  You aren’t required to use any of that, it’s just to help if you follow an agile process.  They don’t offer a free plan, but they do offer a free trial.  The tool is good, but not exceptional.


Unfuddle is a little more expensive than Assembla, but they do offer a free plan.  The interface is far more intuitive and sellable to a business, but they are missing some of the functionality that is available in Assembla.  If you have a small company with very few processes, it’s a fantastic tool.