@ECHO OFF
REM ********************************************************************************
REM
REM This batch file will register the Visual Studio 2005 support for CodeSmith.
REM
REM NOTE: You must own a CodeSmith Professional license
REM 
REM These actions would be completed by the installer normally, but you may wish to
REM register them manually or use this to switch the Visual Studio support
REM between different versions of CodeSmith.
REM
REM NOTE: You may need to change the path to the FRAMEWORKDIR and FRAMEWORKSDKDIR
REM variables.
REM 
REM ********************************************************************************

@SET FRAMEWORKDIR=%SYSTEMROOT%\Microsoft.NET\Framework\v2.0.50727
@SET VS8DIR=%PROGRAMFILES%\Microsoft Visual Studio 8
@SET FRAMEWORKSDKDIR=%VS8DIR%\SDK\v2.0\Bin
@SET SHAREDLICENSESDIR=%PROGRAMFILES%\Common Files\XHEO\SharedLicenses

@ECHO - Moving license files to shared licenses directory...

IF NOT EXIST "%SHAREDLICENSESDIR%" md "%SHAREDLICENSESDIR%"
IF EXIST ..\*.lic MOVE ..\*.lic "%SHAREDLICENSESDIR%"
IF NOT %ERRORLEVEL%==0 goto error

@ECHO - Moved license files to shared licenses directory successfully.
@ECHO.
@ECHO - Installing assemblies into the global assembly cache...

"%FRAMEWORKSDKDIR%\gacutil" /nologo /f /i ..\bin\CodeSmith.Engine.dll
IF NOT %ERRORLEVEL%==0 goto error
"%FRAMEWORKSDKDIR%\gacutil" /nologo /f /i ..\bin\CodeSmith.Gui.dll
IF NOT %ERRORLEVEL%==0 goto error
"%FRAMEWORKSDKDIR%\gacutil" /nologo /f /i ..\AddIns\CodeSmith.BaseTemplates.dll
IF NOT %ERRORLEVEL%==0 goto error
"%FRAMEWORKSDKDIR%\gacutil" /nologo /f /i ..\AddIns\CodeSmith.CustomProperties.dll
IF NOT %ERRORLEVEL%==0 goto error
"%FRAMEWORKSDKDIR%\gacutil" /nologo /f /i ..\AddIns\SchemaExplorer.dll
IF NOT %ERRORLEVEL%==0 goto error
"%FRAMEWORKSDKDIR%\gacutil" /nologo /f /i ..\SchemaProviders\SchemaExplorer.SqlSchemaProvider.dll
IF NOT %ERRORLEVEL%==0 goto error
"%FRAMEWORKSDKDIR%\gacutil" /nologo /f /i ..\SchemaProviders\SchemaExplorer.ADOXSchemaProvider.dll
IF NOT %ERRORLEVEL%==0 goto error
"%FRAMEWORKSDKDIR%\gacutil" /nologo /f /i ..\bin\CodeSmith.VisualStudio.Package.dll
IF NOT %ERRORLEVEL%==0 goto error
"%FRAMEWORKSDKDIR%\gacutil" /nologo /f /i ..\bin\CodeSmith.VisualStudio.CodeGenerators.dll
IF NOT %ERRORLEVEL%==0 goto error

@ECHO - Installed assemblies into the global assembly cache successfully.
@ECHO.
@ECHO - Installing v3.2 publisher policies into the global assembly cache...

"%FRAMEWORKSDKDIR%\gacutil" /nologo /f /i ..\PublisherPolicies\policy.3.2.CodeSmith.Engine.dll
IF NOT %ERRORLEVEL%==0 goto error
"%FRAMEWORKSDKDIR%\gacutil" /nologo /f /i ..\PublisherPolicies\policy.3.2.CodeSmith.Gui.dll
IF NOT %ERRORLEVEL%==0 goto error
"%FRAMEWORKSDKDIR%\gacutil" /nologo /f /i ..\PublisherPolicies\policy.3.2.CodeSmith.BaseTemplates.dll
IF NOT %ERRORLEVEL%==0 goto error
"%FRAMEWORKSDKDIR%\gacutil" /nologo /f /i ..\PublisherPolicies\policy.3.2.CodeSmith.CustomProperties.dll
IF NOT %ERRORLEVEL%==0 goto error
"%FRAMEWORKSDKDIR%\gacutil" /nologo /f /i ..\PublisherPolicies\policy.3.2.SchemaExplorer.dll
IF NOT %ERRORLEVEL%==0 goto error
"%FRAMEWORKSDKDIR%\gacutil" /nologo /f /i ..\PublisherPolicies\policy.3.2.SchemaExplorer.SqlSchemaProvider.dll
IF NOT %ERRORLEVEL%==0 goto error
"%FRAMEWORKSDKDIR%\gacutil" /nologo /f /i ..\PublisherPolicies\policy.3.2.SchemaExplorer.ADOXSchemaProvider.dll
IF NOT %ERRORLEVEL%==0 goto error
@ECHO - Installed v3.2 publisher policies into the global assembly cache successfully.
@ECHO.
@ECHO - Registering assemblies for COM interop...
"%FRAMEWORKDIR%\regasm" /nologo ..\bin\CodeSmith.VisualStudio.CodeGenerators.dll
IF NOT %ERRORLEVEL%==0 goto error
@ECHO - Registered assemblies for COM interop successfully.

@ECHO - Registering Visual Studio package...
reg import "package-install.reg"

@ECHO - Updating Visual Studio setup...
"%VS8DIR%\Common7\IDE\devenv.exe" /setup

GOTO done
:error
@ECHO Non-zero return code %ERRORLEVEL%, script aborted.

:done
PAUSE