Wednesday, 5 May 2010

Using Refresh Files with WebSite Projects to include DLLs

Recently I had a problem whereby my WebSite project (Not WebApplication project) in Visual Studio was missing some DLLs. These are pre-built DLLs that I load from a set location, for example AjaxControlToolkit.dll and log4net.dll.

On my build server whenever a build was done I needed a way to have these files copied to the BIN directory of my website. In a WebApplication or other project these references are specified in the project file (Project.csproj for example), but we don't have a project file for a WebSite project. The WebSite is just a directory of files and any "project" references are included in the Solution file.

The way Visual Studio allows us to include DLL files which are not covered by the project references is with the use of a Refresh file. So for example if I want to include C:\DLLs\AjaxControlToolkit.dll in my WebSite I add it with Add Reference -> Browser -> Choose the file. Visual Studio then puts a file called AjaxControlToolkit.dll.refresh in my bin directory. The presence of this file cause the AjaxControlToolkit.dll to be copied from C:\DLLs\ to the BIN directory of my WebSite each time I build it.

Normally we don't check things in the BIN directory into source control, but Refresh files are the exception. I added my Refresh file in the BIN directory to CVS and when my Build Server did a check out it got the Refresh file, causing the build to copy the DLL into the BIN directory for my built website.

No comments:

Post a Comment