Recently I discovered the wonders of the VBC.EXE command line compiler in the .Net Framework. It is fairly simple to use once you learn what the different command options do. There is a very good reference here.
I have a batch file set up that I run to do the compile. It does the following:
1) Backup the existing DLL.
2) Compile the new DLL.
3) Copy the new DLL to the target server.
This is the code for the batch file:
@echo off
echo Deleting Existing DLL
if exist "dlls\example.dll" del dlls\example.dll
echo Done Deleting DLL
set path=%path%;%SystemRoot%\Microsoft.net\Framework\v1.1.4322\;
echo Building example.dll
vbc.exe @response.rsp
echo Build Complete
echo Making Backup of DLL
if exist "target_server_dll_path\example.dll" xcopy /Y /R target_server_dll_path\example.dll backupdlls\ target_server_dll_path\example.dll
Echo Done Making Backup
Echo Copying DLL to Server
if exist "dlls\example.dll" xcopy /Y /R dlls\example.dll target_server_dll_path\example.dll
echo Done Copying DLL
Pause
Here is the .RSP file:
#add references for other DLLs that the project uses
/r:dlls\example2.dll
/r:dlls\example3.dll
/r:system.dll
/r:system.web.dll
/r:system.data.dll
/r:system.xml.dll
/imports:Microsoft.VisualBasic
/imports:System
/imports:System.Collections
/imports:System.Configuration
/imports:System.Data
/imports:System.Drawing
/imports:System.Web
/imports:System.Web.UI
/imports:System.Web.UI.WebControls
/imports:System.Web.UI.HTMLControls
/nologo
#debug is optional if you want to include debug info in your dll
#the app will run faster if you do not use the /debug option
/debug
#all my code behind files are in directory called codebehindfiles
/recurse:codebehindfiles\*.vb
#define the output file name
/out:dlls\example.dll
/target:library
/rootnamespace:whatever the root namespace of your project is
#/bugreport:bugreport.txt
In the first step I delete the existing dll. This prevents me from later on copying up the existing DLL to the target server if the compile fails. I then run vbc with the response.rsp file I created. After that I make a backup of the existing DLL on the target server I am about the copy the new DLL to and then I copy the new DLL to the target server. If there is a compile error, I uncomment the last line of the response file and it outputs all the comile errors to a file called bugreport.txt.
The PAUSE at the end of the batch file is useful for when you are too lazy to open cmd.exe. It allows you to run the batch file by double clicking on the file in explorer. If you did not have the PAUSE after it was all done the command window would disappear and you would not be able to see the output.
I keep all of these files on a network drive somewhere so someone else can copy .vb files to the codebehindfiles directory and run it if needed. This process works fairly well for me. The only problem I have had so far is that if someone besides me runs it, I get an error when they first run the all on the target server that the type global cannot be found. I believe this has something to do with permissions on the DLL. I will post an update to this when I figure out what the issue is with that.
References used when I was writing my own code:
http://www.flws.com.au/showusyourcode/codeLib/code/CompileSCut.asp?catID=5
http://support.microsoft.com/default.aspx?scid=kb;en-us;319976
http://p2p.wrox.com/archive/aspx_web_matrix/2002-07/3.asp
http://www.angryCoder.com/blog/entries/20030423.html