Posted by: Jeff Germain | December 12, 2009

Post-build Event for Custom Server Object Extensions

While developing ArcGIS Server Object Extensions, I typically run a post-build event in the SOE Visual Studio project to copy the DLL and it dependencies to an output folder outside of the actual Visual Studio project. It is there that I perform the COM registration using REGASM. Until today I have relied on BAT files to do the work for me; uninstall and install. Vish has provided a great VS template for building SOEs you can get here and provided a nice talk at the ESRI dev summit.

To streamline the process, I have created a post-build event to take care of all the work for me. Here’s the script.

   1: $(SolutionDir)_install_ComUtilities\regasm /unregister $(SolutionDir)_install_ComUtilities\CDOT.ArcGisServer.SOEs.LrsSOE.dll

   2: $(SolutionDir)_install_ComUtilities\regasm /unregister $(SolutionDir)_install_ComUtilities\CDOT.ArcGisServer.SOEs.LrsSOEInterface.dll


   4: SC STOP ArcServerObjectManager

   5: ping -n 5 localhost > NUL


   7: DEL $(SolutionDir)_install_ComUtilities\*.dll

   8: DEL $(SolutionDir)_install_ComUtilities\*.tlb

   9: DEL $(SolutionDir)_install_ComUtilities\Logs\*.txt


  11: COPY $(TargetDir)*.dll $(SolutionDir)_install_ComUtilities\*.dll


  13: $(SolutionDir)_install_ComUtilities\regasm $(SolutionDir)_install_ComUtilities\CDOT.ArcGisServer.SOEs.LrsSOE.dll /tlb:$(SolutionDir)_install_ComUtilities\CDOT.ArcGisServer.SOEs.LrsSOE.tlb /codebase

  14: $(SolutionDir)_install_ComUtilities\regasm $(SolutionDir)_install_ComUtilities\CDOT.ArcGisServer.SOEs.LrsSOEInterface.dll /tlb:$(SolutionDir)_install_ComUtilities\CDOT.ArcGisServer.SOEs.LrsSOEInterface.tlb /codebase


  16: SC START ArcServerObjectManager

What’s going on?

* Unregister existing .NET assemblies with COM

   1: $(SolutionDir)_install_ComUtilities\regasm /unregister $(SolutionDir)_install_ComUtilities\CDOT.ArcGisServer.SOEs.LrsSOE.dll

   2: $(SolutionDir)_install_ComUtilities\regasm /unregister $(SolutionDir)_install_ComUtilities\CDOT.ArcGisServer.SOEs.LrsSOEInterface.dll

* Stop the ArcGIS Server Object Manager process and wait 5 seconds while it shuts down. Stopping the SOM kills all SOC processes that have locks on our SOE DLL.

   1: SC STOP ArcServerObjectManager

   2: ping -n 5 localhost > NUL

* Delete DLL, TLB, and custom log files

   1: DEL $(SolutionDir)_install_ComUtilities\*.dll

   2: DEL $(SolutionDir)_install_ComUtilities\*.tlb

   3: DEL $(SolutionDir)_install_ComUtilities\Logs\*.txt

* Copy fresh DLLs to this directory

   1: COPY $(TargetDir)*.dll $(SolutionDir)_install_ComUtilities\*.dll

* Register those .NET assemblies with COM

   1: $(SolutionDir)_install_ComUtilities\regasm $(SolutionDir)_install_ComUtilities\CDOT.ArcGisServer.SOEs.LrsSOE.dll /tlb:$(SolutionDir)_install_ComUtilities\CDOT.ArcGisServer.SOEs.LrsSOE.tlb /codebase

   2: $(SolutionDir)_install_ComUtilities\regasm $(SolutionDir)_install_ComUtilities\CDOT.ArcGisServer.SOEs.LrsSOEInterface.dll /tlb:$(SolutionDir)_install_ComUtilities\CDOT.ArcGisServer.SOEs.LrsSOEInterface.tlb /codebase

* Restart the ArcGIS Server Object Manager

   1: SC START ArcServerObjectManager

Of course, I’ll build an installer for the final delivery to the client.



  1. […] dependencies into that folder, and does all the dirty work. Jeff Germain just threw up a good post on a Post-Build Event that does all this, but here’s the basic […]

  2. […] to roll with this using the post-build event configuration in my previous post, you’ll need to copy over the your SOE’s debug file (.pdb). Do it manually from the bindebug […]

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: