We all have a collection of these, but I use just one Post Build Event while developing:
$(ProjectDir)postBuildDebug.bat "$(ProjectDir)" "$(TargetDir)" "$(DevEnvDir)" "$(TargetName)" "$(TargetFileName)"
Yes, I know that's a cheat! But I find it much easier to manage in a separate file...
So what's in the box?
I don't have a file area yet, so I've placed postBuildDebug.bat at the end of this post if you want a look (apologies for the length).
Notes: This has a number of unused sections, depending on what I am doing at that moment. It also places the dll in the gac, but leaves the pdb and dll file locally as well. That way you can hit debug break points without copying extra files into the gac, but you will see some duplicate reference warnings.
===========================================================================================================================
REM Example of Use: IF $(ConfigurationName)==Debug $(ProjectDir)postBuildDebug.bat "$(ProjectDir)" "$(TargetDir)" "$(DevEnvDir)" "$(TargetName)" "$(TargetFileName)"
ECHO postBuildDebug.bat received call with parameters %1, %2, %3, %4 and %5
SET PROJECTdir=%1
ECHO ...PROJECTdir set to %PROJECTdir%
SET TARGETdir=%2
ECHO ...TARGETdir set to %TARGETdir%
SET DEVENVdir=%3
ECHO ...DEVENVdir set to %DEVENVdir%
SET TARGETname=%4
ECHO ...TARGETname set to %TARGETname%
SET TARGETfilename=%5
ECHO ...TARGETfilename set to %TARGETfilename%
ECHO Changing directory to %PROJECTdir%
CD %PROJECTdir%
SET TWELVEdir=%CommonProgramFiles%\Microsoft Shared\web server extensions\12
SET TEMPLATEdir=%TWELVEdir%\TEMPLATE
SET CONTROLTEMPLATESdir=%TEMPLATEdir%\CONTROLTEMPLATES
SET FEATURESdir=%TEMPLATEdir%\FEATURES
SET IMAGESdir=%TEMPLATEdir%\IMAGES
SET STSADM=%TWELVEdir%\bin\stsadm.exe
SET GACUTIL=%DEVENVdir%..\..\SDK\v2.0\Bin\gacutil.exe
SET MAKECAB=C:\makecab\BIN\MAKECAB.EXE
SET IISAPP=%SystemRoot%\system32\iisapp.vbs
SET GAC=%SystemRoot%\assembly\GAC_MSIL
ECHO Copying source files from "TEMPLATE\CONTROLTEMPLATES\%TARGETname%\*.ascx" to WSS directory "%CONTROLTEMPLATESdir%\%TARGETname%" with switch /y
COPY "TEMPLATE\CONTROLTEMPLATES\%TARGETname%\*.ascx" "%CONTROLTEMPLATESdir%\%TARGETname%" /y
ECHO Copying source files from "TEMPLATE\FEATURES\%TARGETname%\*.xml" to WSS directory "%FEATURESdir%\%TARGETname%" with switch /y
COPY "TEMPLATE\FEATURES\%TARGETname%\*.xml" "%FEATURESdir%\%TARGETname%" /y
ECHO Copying source files from "TEMPLATE\IMAGES\%TARGETname%\*.gif" to WSS directory "%IMAGESdir%\%TARGETname%" with switch /y
COPY "TEMPLATE\IMAGES\%TARGETname%\*.gif" "%IMAGESdir%\%TARGETname%" /y
REM ECHO Copying source files to WSS \TEMPLATE directory
REM CALL XCOPY /e /y TEMPLATE\* "%TEMPLATEdir%"
ECHO Removing assembly %TARGETname% from the GAC at %GAC% using %GACUTIL% /u %TARGETname% /nologo
%GACUTIL% /u %TARGETname% /nologo
ECHO Removing the directory containing the assembly using: RMDIR %GAC%\%TARGETname%, as GacUtil doesn't always do this
RMDIR %GAC%\%TARGETname%
ECHO Checking that %GAC%\%TARGETname% directory no longer exists
IF EXIST %GAC%\%TARGETname% GOTO ERROR1
ECHO Changing Directory to %TARGETdir%
CD %TARGETdir%
ECHO Registering %TARGETfilename% in the GAC at %GAC% using %GACUTIL% /i %TARGETfilename% /nologo
%GACUTIL% /i %TARGETfilename% /nologo
ECHO Checking that %GAC%\%TARGETname% now exists again
IF NOT EXIST %GAC%\%TARGETname% GOTO ERROR2
REM ECHO Installing feature with STSADM
REM %STSADM% -o installfeature -filename %TARGETname%\feature.xml -force
REM ECHO Activating feature with STSADM
REM %STSADM% -o activatefeature -name %TARGETname% -url http://Server/Site/Subsite
ECHO Recycling app pool for this app only - use iisreset for a full recycle
%IISAPP% /a "Sharepoint - 81" /r
REM IISRESET
GOTO End
:Error1
ECHO Error1: GAC uninstall of %GAC%\%TARGETname% using %GACUTIL% failed - please review details Build output
EXIT 1
:Error2
ECHO Error2: GAC install of %TARGETdir%\%TARGETfilename% to %GAC%\%TARGETname% using %GACUTIL% failed - please review details Build output
EXIT 2
:End
ECHO Completed OK