Skip to content

Instantly share code, notes, and snippets.

@diyan
Created January 6, 2012 19:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save diyan/1572015 to your computer and use it in GitHub Desktop.
Save diyan/1572015 to your computer and use it in GitHub Desktop.
Pre and Post build action for .NET/COM component which will be used in Classic ASP application
echo NOTE that right now pre build action will be executed...
@echo off
set APP_CMD="C:\Windows\System32\inetsrv\AppCmd.exe"
echo STEP 1. Recycle IIS 7 Application Pool named SomeAppPool because it may locked .NET assembly with COM component
%APP_CMD% recycle apppool /apppool.name:SomeAppPool
===============================================================================================
echo NOTE that right now post build action will be executed...
@echo off
set GACUTIL_EXE="C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools\x64\gacutil.exe"
set REGASM_EXE="C:\Windows\Microsoft.NET\Framework64\v4.0.30319\RegAsm.exe"
echo STEP 1. Unregistering all version of assembly from GAC if them was already registered...
%GACUTIL_EXE% /uf $(TargetName)
echo STEP 2. Unregistering .NET component from COM registry if it was already registered...
%REGASM_EXE% $(TargetPath) /unregister
echo STEP 3. Generate COM type library from .NET assembly and register .NET assembly as COM component
%REGASM_EXE% $(TargetPath) /tlb:$(TargetDir)$(TargetName).tlb
echo STEP 4. Register .NET assembly in GAC
%GACUTIL_EXE% /if $(TargetPath)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment