There’s a great post here detailing how to add nested elements within a custom NAnt task. I was writing a task to create IIS websites, and wanted to be able to specify multiple bindings, for example: <IIS.Website.Create name=”MySite” physicalPath=”path”> <bindings> <binding type=”http” ip=”1.2.3.4″ port=”8080″ host=”domain.com” /> <binding type=”net.msmq” host=”localhost” /> </bindings> </IIS.Website.Create>…
I’ve just spent the day getting ANTLR set up to work within a Visual Studio 2010 solution, which wasn’t without pain. While there is quite a lot of (mostly useful) documentation, finding exactly what you want can be difficult, and the examples don’t necessarily work, which is always frustrating! Hopefully…
New installation of Visual Studio 2010? You need: Productivity Power Tools PowerCommands You’ll never look back. Configure which additions are enabled by looking for the Productivity Power Tools and PowerCommands options trees underneath Tools -> Options.
This is a definite gotcha. I was writing a NAnt task that uses the registry to check for the existence of certain installed programs. I hit a problem where when I ran the task directly, it worked fine, but when I ran it through NAnt, it failed. Turns out this…
Easy as: sp_msforeachtable ‘ALTER TABLE ? NOCHECK CONSTRAINT all’ GO sp_msforeachtable ‘DELETE ?’ GO sp_msforeachtable ‘ALTER TABLE ? CHECK CONSTRAINT all’ GO
When you want to access nested properties on an object, e.g. Person.Address.Postcode, it’s annoying and bloated having to write this as a series of variable assignments and null checks at each stage if the properties are nullable. The set of extensions below allows the following example: public string GetSomething(A myClass)…
using System; namespace Extensions { public static class DateTimeExtensions { public static int Age(this DateTime birthDate) { return Age(birthDate, DateTime.Today); } public static int Age(this DateTime birthDateTime, DateTime atDateTime) { var birthDate = birthDateTime.Date; var atDate = atDateTime.Date; var age = atDate.Year – birthDate.Year; if (birthDate.AddYears(age) > atDate) { age–;…
Simple, but a few non-obvious things required: 1. Add a reference to System.Windows.Forms 2. Add a [STAThread] attribute above the Main method (see here for more information) 3. Now you’re ready to use the methods on Clipboard to write to the clipboard: … using System.Windows.Forms; namespace MyNamespace { public class…
Whereas ELMAH used to work pretty much straight out of the box, with MVC 3, a change to the global.asax.cs template means that ELMAH won’t automatically catch all errors, since MVC 3 has some built in error handling when custom errors are enabled. To remove this and let ELMAH catch…
You need to add a new framework configuration which (still?) doesn’t come by default with the download of NAnt. Insert the following into your NAnt.exe.config file (alongside the similar looking framework configurations): <framework name=”net-4.0″ family=”net” version=”4.0″ vendor=”Microsoft” description=”Microsoft .NET Framework 4.0″ sdkdirectory=”${path::combine(sdkInstallRoot, ‘bin’)}” frameworkdirectory=”${path::combine(installRoot, ‘v4.0.30319’)}” frameworkassemblydirectory=”${path::combine(installRoot, ‘v4.0.30319’)}” clrversion=”4.0.30319″> <runtime> <probing-paths> <directory name=”lib/net/2.0″ /> <directory name=”lib/net/neutral” /> <directory name=”lib/common/2.0″ /> <directory name=”lib/common/neutral” /> </probing-paths> <modes>…