2

I'm attempting to automate signing of an ArcGIS Add-In using a post build event in visual studio that triggers a batch file (which subsequently triggers ESRISignAddIn utility). Running the batch file manually through command prompt works fine, the Add-In is signed successfully. However if I attempt to run the batch file in the post-build event, it returns an error saying the Add-In file cannot be found. I've noticed that by the time the build process gets to the post-build stage, only the DLLs are created - the Add-In file is not, hence the batch file cannot find it. It appears the Add-In file is created AFTER the post-build event (illogical, I know).

I have tried adding the batch commands to the post-build event command line (in project settings > compile > build events), and have also tried adding this directly to the project file XML:

<Target Name="AfterBuild">
    <Exec Command="&quot;$(ProjectDir)Post_Build.bat&quot; &quot;$(TargetDir)my.esriAddIn&quot;" />
</Target>

Seems that 'post build' and 'after build' events are both executed before the esriaddin file is built, useless!

Has anyone had any experience working with post-build events and ArcGIS Add-Ins? I want to know if it's possible to force the Add-In file (my.esriaddin) to be created before the post-build event.

My last resort solution is to execute the build and then the batch file using a build runner (e.g. finalbuilder), but would ideally like to keep everything in the same project.

2

I had a similar problem in that I needed to copy the add-in output file to another directory using a post-build event. Like you, I had a problem in that the add-in file hadn't been created by the time the post-build event fired.

I believe I may have a solution for you. Instead of the target you are using above, try this:

  <Target AfterTargets="RunArcGISPostPackageEvent" Name="SignMyAddin">
    <Exec Command="&quot;$(ProjectDir)Post_Build.bat&quot; &quot;$(TargetDir)my.esriAddIn&quot;" />
  </Target>

For further clarity, in my .csproj file I have an import (presumably added by Esri) that says this:

<Import Project="$(MSBuildExtensionsPath)\ESRI\ESRI.ArcGIS.AddIns.targets" Condition="Exists('$(MSBuildExtensionsPath)\ESRI\ESRI.ArcGIS.AddIns.targets')" />

If I open that imported file, there is a target in there with a name RunArcGISPostPackageEvent, which as far as I can tell is the last thing Esri is doing to finish up creating the *.addin file. So using the AfterTargets attribute on a custom target will wait until after that other target is done before running. If the above doesn't work, you might try AfterTargets=PackageArcGISAddInContents as that is another target in the imported project.

I'm not an expert so there may be a better way, but this has worked for me.

  • You are an absolute saviour. This solution works! Many thanks for your help, much appreciated. – pvdev Jul 25 '14 at 11:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.