A blog about SQL Server, SSIS, C# and whatever else I happen to be dealing with in my professional life.

Find ramblings

Wednesday, March 10, 2010

Post-build event

I was looking for an article I had seen that discussed how to use the installer project to simplify my SSIS component deployment and I ran across Todd McDermid's article The Post-Build Command Line for SSIS Custom Objects (Updated)

That's pretty.  Way more elegant and reusable than what we are doing here http://billfellows.blogspot.com/2009/09/visual-studio-build-macros.html We just copy the DLL into PipelineComponents and Tasks, regardless of what it is.  However, the batch script failed on a default machine because gacutil is not part of the standard path.  Sure, you can add it in there. Or you can add some guessing logic into those scripts.  I went with the later.

Using the files on Todd's Skydrive, I added my sauce.  I suspect using $(FrameworkSDKDir) will provide the most consistent reference for gacutil which is why it's listed last

SET GACUtil=unset

REM Not sure why one would choose windir vs SystemRoot
REM both seem to evaluate to same value on available systems
SET GACUTIL_PATH_win1="%windir%\system32\dllcache\gacutil.exe"
SET GACUTIL_PATH_win2="%windir%\gacutil.exe"
SET GACUTIL_PATH_v1="%windir%\Microsoft.NET\Framework\v1.1.4322\gacutil.exe"
SET GACUTIL_PATH_v2005="%ProgramFiles%\Microsoft Visual Studio 8\SDK\v2.0\Bin\gacutil.exe"
SET GACUTIL_PATH_v2008="%ProgramFiles%\Microsoft SDKs\Windows\v6.0A\Bin\gacutil.exe"
SET GACUTIL_PATH_v2008a="%ProgramFiles%\Microsoft SDKs\Windows\v6.0A\Bin\gacutil.exe"
SET GACUTIL_PATH_framework="$(FrameworkSDKDir)bin\gacutil.exe"

IF EXIST %GACUTIL_PATH_win1% SET GACUtil=%GACUTIL_PATH_win1%
IF EXIST %GACUTIL_PATH_win2% SET GACUtil=%GACUTIL_PATH_win2%
IF EXIST %GACUTIL_PATH_v1% SET GACUtil=%GACUTIL_PATH_v1%
IF EXIST %GACUTIL_PATH_v2005% SET GACUtil=%GACUTIL_PATH_v2005%
IF EXIST %GACUTIL_PATH_v2008% SET GACUtil=%GACUTIL_PATH_v2008%
IF EXIST %GACUTIL_PATH_v2008a% SET GACUtil=%GACUTIL_PATH_v2008a%
IF EXIST %GACUTIL_PATH_framework% SET GACUtil=%GACUTIL_PATH_framework%

I then replaced all mentions of GACUtil with %GACUtil%  and voilĂ !

No comments: