- Download and install the MVC2 framework from http://www.asp.net/downloads/
- Download and install the latest NUnit framework from http://www.nunit.org/index.php?p=download
- Download and uncompress the Rhino Mock framework from http://www.ayende.com/projects/rhino-mocks.aspx
- Download and uncompress the Windsor 2.1 framework from http://www.castleproject.org/castle/download.html
- Open Visual Studio and create a new ASP.NET MVC 2 Web Application Project within Visual Studio 2008 (change the names to suit your template, location does not matter since we'll be exporting as a template)
- Change the name of the Test project to suit your needs and make sure that the Visual Studio Unit Test test framework is selected.
- In the Test project remove the reference to Microsoft.VisualStudio.QualityTools.UnitTestFramework and add references to the project for the following dlls and verify that all of their properties are set to Copy Local (make sure to either add these to the GAC or a semi-permanent location or network share or you will end up breaking the template if that directory changes). I also, decided that in order to be able to immediately compile when a new project is created with this template, I removed the reference to the base project from the test project and removed all code that referenced the VS Unit Testing framework.
- Castle.Core
- Castle.DynamicProxy2
- Castle.MicroKernel
- Castle.Windsor
- nunit.framework
- Rhino.Mocks
- Save all changes and go to File > Export Template
- Select the Project template option and verify that the MvcApplication.NUnitTests is selected as the project from which to create a template
- Click Next
- Change the template name to MvcApplication.NUnitTests.cs
- Change the template description to something meaningful, such as - ASP.NET MVC Web Application NUnit project template
- Keep both the Automatically import the template into Visual Studio as well as the Display an explorer window on the output files folder options selected - the end result should be a single zip file that will be displayed when in explorer when we're finished.
- Click Finish and Windows Explorer popups up with the output zip file (it should default to
\Visual Studio 2008\My Exported Templates ). Copy this file to C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\ProjectTemplates\CSharp\Test (assuming you're running the 64-bit version of Windows 7, adjust this path according to your environment) - Close all open instances of Visual Studio
- Open the Visual Studio 2008 Command Prompt (as Administrator) and run the following command to install the template (the command prompt can be found under Start > All Programs > Microsoft Visual Studio 2008 > Visual Studio Tools > Visual Studio 2008 Command Prompt) - Note: this may take a couple of minutes depending on your computer and templates available
- devenv /installvstemplates
- Close the command prompt
- Create a new file with the following contents (editing the paths to match your environment)
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\9.0\MVC2\TestProjectTemplates\NUnit]
"Template"="MvcApplication.NUnitTests.cs.zip"
"Path"="CSharp\\Test"
"TestFrameworkName"="NUnit Test"
"AdditionalInfo"="http://www.nunit.org/index.php?p=home"
"Package"=""
- Choose a file name (such as - NUnit Test template Example.reg) and save the file to a location that you can navigate to easily
- Open a normal command prompt (with adminstrative priviledges) and navigate to where you saved the file created in the previous step
- Run the following -
regedit.exe /s "[path to file]\NUnit Test template Example.reg" - Open Visual Studio and Create a new MVC project with the new template for NUnit


No comments:
Post a Comment