People have already posted about how to optimise the start up times of EPiServer here and here. One of the common techniques is to exclude assemblies from being scanned at application start up by setting them as exclusions in the EPiServer framework config.
I like this idea as it enhances the development experience and can improve production deployments too by speeding up application start times. However I was never satisfied that I could never be certain I was excluding the right assemblies or if there were assemblies that I could safely exclude. There is a tool on http://www.epiwiki.se that tries to automatically generate a list of assembles to exclude but it wasn't always reliable (sorry guys). I found that it frequently included assemblies that should not be excluded (for example EPiServer.UI or Dropit.Extension.UI). I looked into this and discovered that it only scanned for assemblies that use the EPiServer initialisation system but not assemblies that used any GuiPlugInAttributes (i.e. anything that derives from EPiServer.PlugIn.PlugInAttribute). By excluding assemblies that contain GuiPlugIn attributes it means that unexpected issues can occur (for example missing Composer tools in admin mode or custom plug ins not appearing in edit or admin mode).
So I set out to create a tool that could be used during build to scan for and check for the assemblies that could be safely excluded in the EPiServer framework config. Perhaps more importantly it also checks for assemblies that are excluded when they shouldn't be.
The tool generates errors for assemblies that are excluded from initialisation scanning when they contain plug ins or initialisation modules. It also generates warnings for assembles that could be excluded (therefore improving start up times).
What the tool does
- Scans all assemblies in the \bin folder and checks for all assemblies that use the EPiServer initialisation system or has any GuiPlugIn attributes
- Inspects the <episerver.framework><scanAssembly> element for assemblies that are excluded from scanning
- If an assembly contains an EPiServer initialisation module or GuiPlugIn and is in the exclude list generates an error
- If an assembly doesn't contain an init module or GUI plug and is not in the exclude list generates a warning
How to include EPiScanner in your build
A custom build task is required to use this tool. The following steps explain how to include in your build:
- Right click on your EPiServer .proj file
- Select "Unload Project":
- Right click the prioject file and click "Edit <your project name>.csproj"
- Scroll to the bottom of the file
- Add the following build step before the closing </Project> tag:
Now when you build your project the tool you will generate errors for assemblies that are in the exclude list in EPiServer framework when they shouldn't be and warnings when they could be safely excluded but are not as shown below:
Note! Obviously this task has a performance implications in itself so you may not want to include it in every build configuration!
How to get it
It can be downloaded from CodePlex.
This tool requires Visual Studio 2010 and projects running .net 4.0. The .exe also has a dependency on EPiServer.dll and EPiServer.Framework.dll. If these are not in the \bin folder of your site then the tool may not function correctly.
I hope this tool will be useful to people. I'd be happy to hear your feedback on the comments below or on @davidknipe. In particular I'd be happy to hear ideas on what could be added to the project in order to further enhance EPiServer configuration checks.