Thursday, December 30, 2010

My standard .hgignore

One of the things that I do as soon as I am starting on a new project is create either a Git or Mercurial repository for the project.  At the moment I tend to be using Mercurial more that Git, because bitbucket offerss free private repositories.

One of the things you want to do when setting up the repository is add an ignore file so that you don’t add build artefacts and other user specific files to the repository.  You don’t want to add these files as everyone that works on the project will be constantly changing these files which will pollute your history with lots of unnecessary changes that don’t really effect the project at all. 

I thought I might share my current default .hgignore file with you all.  I am curious what other people have in theirs.

# use glob syntax.
syntax: glob

*.suo
*\bin\*
*\Bin\*
*\obj\*
*\_ReSharper*
*.ReSharper.user
glob:Source/Shell/publish/
*.csproj.user
*\TestResult.xml
*.csproj.VisualState.xml
*\App_Data\*

Monday, December 27, 2010

Deploying ASP.NET MVC 3 RC2

I was recently working on a ASP.NET MVC3 proof of concept application.  My client wanted to be able to preview my work with daily builds.  It was suggested that the simplest way for me to go about this would be to deploy it to Azure.  This turned out to work fairly well, but I did have a few dramas getting things to work.

The main problem that I had was making sure that I deployed all of the MVC assemblies along with my app.  This is required as it isn’t part of the .net framework.  I found a few sites indicating which assemblies were needed, but I found I had to add a few more to list before things worked.  This was a frustrating process, because I had to wait 15mins every time a tried something that didn’t work before I knew that it wasn’t going to work. 

To hopefully save others from having the same problem I have included a list of the assemblies I had to deploy along with my app to get it working.  To include a referenced assembly in the deployment make sure that Copy Local option is set to True in the properties of assembly reference.

Without further ado the assemblies you should include are:

  • Microsoft.Web.Infrastructure
  • NuGet.Core
  • System.Web.Helpers
  • System.Web.Mvc
  • System.Web.Razor
  • System.Web.WebPages
  • System.Web.WebPages.Administration
  • System.Web.WebPages.Deployment
  • System.Web.WebPages.Razor
  • WebMatrix.Data

I was quite surprised to see NuGet.Core and WebMatrix.Data in there as I can’t quite see why the MVC framework should have dependencies on these, but my application did fail to start trying to load these assemblies if I didn’t include them, so it would appear that it was necessary.

Tuesday, December 14, 2010

Windows Phone 7 Theme Resources

Recently I have been working on a windows phone 7 application.  In a few of the project template XAML files I noticed references to some StaticResource styles and brushes.  I couldn’t find a nice way in Visual Studio or Expression Blend to see a list of these resources, so I set out to find one on the web.  After a brief search I found the Theme Resources for Windows Phone page on MSDN.  The page lists all of the available resources included in the wp7 theme, but doesn’t show you want the look like.  I decided to make an app which would show the the theme resources to make choosing the correct resource easier.

Please welcome Theme Resource Preview for windows phone 7!

imageA view of the font name resources

The application contains pretty much all of the resources except for the colour resources.  The reason I left the colours out of it is that they seemed to be the same as the brush so figuring out what colour to use shouldn’t be very difficult.

imageimageimageimage
Some more shots of the application in action

I have posted the source code for the application to my bit bucket account so for anyone who is interested you can grab a copy of the source here: https://bitbucket.org/caleb_vear/wp7themeresourcepreview

Or for your convenience you can use one of the following hg commands to clone (one is https and the other ssh):

hg clone https://caleb_vear@bitbucket.org/caleb_vear/wp7themeresourcepreview
hg clone ssh://hg@bitbucket.org/caleb_vear/wp7themeresourcepreview
The only requirement for the application is that you will need a copy of Visual Studio 2010 and the Windows Phone development tools.  The express version of Visual Studio should to just fine, although I used ultimate.

Wednesday, November 24, 2010

SkipObject Bug Solution

Yesterday I blogged about a bug I was having while implementing a serializer for my append only file storage.  I blogged about it here.

The problem with the code is found by gaining a better understanding of how the += operator works:

x += y;

Is equivalent to writing

x = x + y;

The problem in this case can is explained in the following snippet:

The fixed version of the function can be seen here:

Tuesday, November 23, 2010

Where is the bug?

I was recently working on an append only file data store.  I am building a list of the data at load time.  The code that builds the index doesn’t know how to read anything, but the header information for an object.  I have another class which implements ISerializer to handle reading and writing the objects that I want to store.  The ISerializer interface has a method called SkipObject which is supposed to advance the the stream past the object, which will have it at the start of the next object’s header.  The serializer can know how long the object is because the first 4 bytes of the object make up an integer that is the length of the object in bytes.

Here is what I initially had for the SkipObject method:

Can you spot the bug? I'll post the answer tomorrow.

Saturday, October 30, 2010

Customising the SharePoint search box

On a recent project I worked on some custom branding for a SharePoint site.  One of the things I wanted to do to help layout the page they way the wanted was to change the mark-up that was used by the search text box.  I found an excellent MSDN article detailing how to do this and as it worked splendidly I decided to share it with you.  Head on over to the article here: How to: Customize a Delegate Control

Monday, October 11, 2010

ACT Libraries Rock!

I needed to meet up with a fellow Readifarian today so that we could work together on a joint PD (professional development) project.  We needed to decide on a place to work and I suggested the Woden library.  The last time I went there they had a couple of tables upstairs where people could study, the only facilities were the tables and chairs, but I figured that was better than a table at a coffee shop. 

When we arrived today we were pleasantly surprised to discover a fantastic setup including free WiFi internet and power outlets at some of the tables.  We were able to whip out our laptops and get straight into business in a clean, quite environment with absolutely no hassles.

If you are in the ACT and need a nice peaceful place to work I highly recommend checking out the local library.