Friday, 28 May 2010

Local development SMTP server

If you are writing an application or website function that sends out emails you may want to use a local SMTP that doesn't actually forward on the email. This is useful when testing bulk mail, as you wouldn't want to send out actual emails to multiple test addresses. There are many apps out there that perfrom this function. The one that I use is SMTP4dev which is available from CodePlex.

Wednesday, 12 May 2010

Dual screen wallpaper on Windows 7

If you have a dual, triple or quad screen setup, you can have a desktop wallper span all of them. I am using a free piece of software to do this called DisplayFusion, you can download this from http://www.binaryfortress.com/displayfusion/

Friday, 7 May 2010

Aborting a Sitecore event

So you've managed to intercept a Sitecore event, but you now need to stop all other events from occurring. I've had to do this when creating an alias to make sure it doesn't effect any other item. So we check all the possible clashes in the item:creating event, if one is found we won't to stop all further processing.

To stop the further processing all you need to do is call the following:

SitecoreEventArgs.Cancel(args);

You may also want to pass a message to the user, so just add a call to SheerResponse.

SheerResponse.ShowError(shortDescription, longDescription);

Wednesday, 5 May 2010

Update AssemblyInfo as part of the build process

I use TeamCity to build by code as part of continuous integration. One of the tasks I tend to do is to update the AssemblyInfo file with the current build number.

First you need to ensure you have installed the open source project MSBuild Community Tasks, downloadable from here.

Then the code to do this is:
<Target Name="PreBuildTasks">
<PropertyGroup>
<Version>$(BUILD_NUMBER)</Version>
</PropertyGroup>
<MSBuild.Community.Tasks.AssemblyInfo
CodeLanguage="CS"
AssemblyCompany="CompanyName"
AssemblyCopyright="Copyright (c) CompanyName2009"
AssemblyDescription="Description"
AssemblyFileVersion="$(Version)"
AssemblyVersion="$(Version)"
AssemblyTitle="Titlek"
Guid="1938930d-a5f3-4045-a5f3-f5b930d70ade"
AssemblyProduct="Product name"
OutputFile="$(MSBuildProjectDirectory)\ProjectName\Properties\AssemblyInfo.cs" />
</Target>

Please note this has only be tested to work on TeamCity.

Create build file from solution file

You can create a build file from your solution for use with MSBuild. Useful if you are using any automated build tools like TeamCity.

To do this, open up the "Visual Studio 2008 Command Prompt"
Navigate to the folder containing your solution file
Enter the following:

Set MSBuildEmitSolution = 1
msbuild solutionname.sln


Once complete you should see a file in the folder called solutionname.sln.proj which is now your build file. You can edit this build file as required. I tend to add pre build code to update AssemblyInfo.cs and post build code to fire off unit tests and to package up the final output.