Post Build Events in VSTA

Post build events are very important in VSTA (versions 1 and 2).  They are used to install files in the GAC, organize DLL's for add-in discovery, and in VSTA v 2, to rebuild the pipeline. 

Here are the files used in post build events by the ShapeApp samples, the commands which run them, and some information about them.

File:  InstallInGAC.bat

Description:  Used by a proxy to install the proxy assembly in the GAC.

Command: call "$(ProjectDir)InstallInGac.bat" "$(TargetPath)"

Notes:  This file changed from VSTA v 1 to VSTA v 2.  The VSTA v 1 InstallInGAC.bat file looks for the GACutil tool in %programfiles%\Microsoft Visual Studio 8\SDK\v2.0\Bin\gacutil where Visual Studio 2005 places it.  The VSTA v 2 InstallInGAC.bat file looks for the GACutil in %WindowsSDKPath%bin\ (WindowsSDKPath is read from the registry) where Visual Studio 2008 places it.  We offer a version, InstallInGAC_0508.bat, which looks in both locations and will work with Visual Studio 2005 and Visual Studio 2008. 

Command for our version:  Call "$(ProjectDir)InstallInGac_0508.bat" "$(TargetPath)"

 

 File:  InstallForVB.bat

Description:  Used by a proxy to copy the proxy assembly into the pipeline and rebuild it.

Commands: call "$(ProjectDir)InstallForVB.bat" "$(TargetPath)"

Notes:  This file is new for VSTA v 2 and is generally used together with the InstallInGAC file.

 File:  InstallAddIn.js

Description:  Used by add-ins to move the assembly to %My Documents%\<HostID>\AppAddIns in a folder with the same name as the assembly.

Commands: cscript "$(ProjectDir)InstallAddIn.js" "$(TargetPath)" "ShapeAppCSharp\AppAddIns\$(TargetName)"

Notes:  In the command above, replace ShapeAppCSharp with the HostID, or the value specified in the registry for the entry UserFilesFolderName.  This file is the same for VSTA v 1 and v 2.  This post build event moves the add-in assembly to a programatically searchable location, %My Documents%\<HostID>\AppAddIns. 

In VSTA v 1, this location is used for the appAddInPath variable which is set in the Connect method and in the LoadAppAddIns method to load add-ins in the extension class.

In VSTA v 2, this location is used for the AppLevelAddInPath variable which is used in the LoadAppLevelAddIns method to load add-ins in the VstaRunTimeIntegration class.

The best way to get add-ins to use this post build event, is to specify it in the template.  Unfortunately, there is no way to add the InstallAddIn.js file and post build event through ProjectGen.  Instead, the template created by ProjectGen must be manually updated then (re)registered with VSTA.  For more information on how to do this, check out my blogs on how to add this post build event, and how to update an existing template.

Posted Feb 19 2008, 01:56 PM by Melody
Copyright Summit Software Company, 2008. All rights reserved.