Monday 24 November 2014

NUnit Web.config

When using NUnit to test a web project, by default NUnit won't read the Web.config, it is only looking for a config file named TestProjectNamespace.dll.config.

We can quickly configure Visual Studio so the web.config file is copied (and renamed) from your web project to the NUnit build folder.

Add the web.config File as a Link
  1. Right click on NUnit project in Visual Studio
    Add > Existing Item
  2. Navigate to the web.config file in the web project
  3. Select the web.config file
    click on the arrow beside the Add button > Add As Link

Edit the NUnit Project File
Use a text editor to edit the NUnit project file, you will be able to find the lines where you have added the web.config file.

Change from:
    <None Include="..\Other.Project\Web.config">
      <Link>Web.config</Link>
    </None>

To:
    <None Include="..\Other.Project\Web.config">
      <Link>Namespace.dll.config</Link>
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </None>

This will copy the linked file and rename it so NUnit will find it.

Sunday 2 November 2014

Visual Studio Won't Start

Visual Studio 2013 started hanging on startup, a CPU core would be maxed out but there would be no events in Process Monitor.

I'm sure the same debugging rules apply to 2010 & 2012...

  1. It will probably run in safe mode: devenv.exe /safemode
  2. Might be worth a bet resetting settings: devenv.exe /resetsettings
  3. Or viewing a log for warnings: devenv.exe /resetsettings
    Check out the log file in:
    C:\Users\_USERNAME_\AppData\Roaming\Microsoft\VisualStudio\_VERSION_
  4. As a last resort (takes ages) try repair by Control Panel > Add/ Remove Programs