Category Archives: Code

Software Development

Can’t open Asp.Net MVC2 project in Visual Studio 2010 – Microsoft.WebApplication.targets was not found

You try to open an MVC2 project that worked on a previous machine but won’t open on your new machine? The error message you get when you try to open the project is:

error MSB4019: The imported project “C:\Program Files\MSBuild\Microsoft\VisualStudio\v9.0\WebApplications\Microsoft.WebApplication.targets” was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.

Possibly your new machine has never had Visual Studio 2008 on it, whereas your old machine did. In which case the solutions is:

  1. Find a machine on which VS2008 has been installed
  2. Copy the contents of C:\Program Files\MSBuild\Microsoft\VisualStudio\v9.0\WebApplications to your new machine


How to create an NUnit test project that is also a self-running console app .exe

  1. Create your NUnit Test project as a Windows Console Application, not as a Class Library.
  2. Then make your main Program look like this:
    public class Program
        static void Main(string[] args)
                new[]{Assembly.GetExecutingAssembly().Location }
        [TestCase("Aa - Bb")]
        public void WhenValidatingForename_should_accept_valid_characters(string validInput)
            var result= new ClassUnderTest().Validate(validInput);
        public void WhenValidatingForename_should_reject_invalid_characters(string invalidInput)
            var result= new ClassUnderTest().Validate(invalidInput);
  3. Then, add a reference not only to nunit.framework.dll but also to nunit-console-runner.dll

You now have a self-running executable that runs all your tests, but still behaves in the usual way in a build script, or when running tests inside Visual Studio with TestRunner or Resharper or similar.
NB You may need to check if your build scripts are hard-coded to expect a Test project to be a .dll.

Regular Expressions to NOT match a pattern

Negative lookarounds are usually what you’re after:

Negative Lookbehind

  • (?<!status )code

    matches code not preceded by status

  • (?<!status )(?<!post)code

    matches code not preceded by status or by post

Negative Lookahead

  • code(?!smith)

    matches code not followed by smith

  • code(?!smith)(?!d)

    matches code not followed by smith or by d

Negated Character Classes

But to not-match just a single character you can do it with character a class:

  • code[^d]

    matches code but not coded

  • code=[^0-9]

    matches code=X where X is not a digit

Learn more…

Software Quality — the Whole not the Parts

Ben Higginbottom makes a significant point right at the top of this question about the Knight Capital fiasco:

Was the Knight Capital fiasco related to Release Management? On August 1, 2012, Knight Capital Group had a very bad day, losing $440 million in forty-five minutes. More than two weeks later, there has been no official detailed explanation of …

Ben Higginbottom: Nightmare scenarios like this are not the result in the failing in any one discrete components that can be ‘fixed’ simply and sweetly by improving the process, but by small failures in multiple domains (I’m kind of reminded of a fatal accident investigation). So coding error, gap in the unit testing, weak end to end testing and poor post release testing coupled with a lack of operational checks when live. I can understand the desire for a ‘silver bullet’ fix, but in any complex system I’ve never known them to exist.

Sometimes, it’s the whole, not the parts, that needs fixing.