Talk, talk and more talk about BizTalk

Post build task to add .Net component to GAC

Occasionally I’ll need to write a helper .Net function to fill the gap where standard BizTalk functionality is not flexible enough.  This is usually often enough that I follow a pattern of having a “.Helpers” assembly associated with every BizTalk application I develop.

These Helper assemblies compile and can be referenced by other projects in the solution just fine, but when the application is later deployed, or exported as an MSI package, we usually find one of the following occurs:

  • A referenced DLL is missing from the GAC (easily fixed),
  • An older, stale, version of the Helper dll is exported in the packaged MSI, due to subsequent versions of the Helper not having been updated in the BizTalk metabase
The following Post-build Event Command Line will ensure the Helper DLL is successfully added to the GAC on the local machine, then update the BizTalk application to include the latest binary copy of the DLL in its resource manifest:

"%ProgramFiles(x86)%\Microsoft SDKs\Windows\v7.0A\Bin\gacutil.exe" /i $(TargetPath)
btstask.exe AddResource -Application:{BizTalk Application Name} -Type:System.BizTalk:Assembly -Overwrite -Source:$(TargetPath)

Be sure to remember to replace the {BizTalk Application Name} token with the relevant Application Name, and change the “Run the post-build event” drop-down option to “When the build updates the project output”

Edit: For 32-bit BizTalk environments, replace %ProgramFiles(x86)% with %ProgramFiles%

Edit 2: When working with BizTalk 2010 (and later), the gacutil executable will be found in a different location.  This is due to the Framework 4.0 GAC being both structured and located differently to earlier versions.  The compatible version of gacutil.exe can now be found at:

"%ProgramFiles(x86)%\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools\gacutil.exe"


August 22, 2011 - Posted by | BizTalk

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: