Select to view content in your preferred language

Cannot copy esriAddIn in post-build event

4313
3
11-10-2015 05:51 AM
MaraStoica2
Emerging Contributor

I'm trying to set up a post build event in Visual Studio 2010 that copies the .esriAddIn file to a specific folder after it's built. However, it does not work. After some more digging I got to an error saying that the file does not exist. I added an echo and a timer to see if the code even runs, and everything runs fine, but the actual esriAddIn file doesn't get created until after the post-build event finishes running. I'm out of ideas how to make this work.

Here's the code I'm using:

start xcopy /Y /R "C:\Users\codergrl\Documents\Visual Studio 2010\Projects\ArcMapAddin1\ArcMapAddin1\bin\Release\ArcMapAddin1.esriAddIn" "C:\Users\codergrl\Documents\AddIns"

This works fine if I put it in a .bat file, but gives me the "file not found" error if I put it in the post-build event in VS.

Any ideas?

0 Kudos
3 Replies
JonMorris2
Frequent Contributor

It's odd that the post-build event fires before the build has finished. You can get round it by calling a batch file that waits for the addin to be present before copying. For example:

@echo off


for /l %%a in (1,1,10) do (
  echo attempt %%a
  if exist c:\temp\my.esriAddIn goto :doCopy
  ping 127.0.0.1 -n 2 > nul
)
goto :end


:doCopy
echo copying...
REM add copy command here


:end
echo done
0 Kudos
MaraStoica2
Emerging Contributor

Thanks for that Jon Morris Unfortunately that doesn't help. Below is the output I get. It waits until the post-build is finished before it creates the esriAddIn file. (I even tried waiting for 50 seconds, it just sits there...)

------ Rebuild All started: Project: ArcMapAddin1, Configuration: Release Any CPU ------

  ArcMapAddin1 -> C:\Users\codergrl\Documents\Visual Studio 2010\Projects\ArcMapAddin1\ArcMapAddin1\bin\Release\ArcMapAddin1.dll

  attempt 1 

  attempt 2 

  attempt 3 

  attempt 4 

  attempt 5 

  attempt 6 

  attempt 7 

  attempt 8 

  attempt 9 

  attempt 10 

  done

  Successfully created Add-in "ArcMapAddin1" ->  'C:\Users\codergrl\Documents\Visual Studio 2010\Projects\ArcMapAddin1\ArcMapAddin1\bin\Release\ArcMapAddin1.esriAddIn'.

========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========

0 Kudos
JonMorris2
Frequent Contributor

Yes, it looks like packaging takes place after the post-build event, which isn't much use. Here is some of the output from building one of my addins:

  ...

  Copying file from "C:\Users\virtual\Documents\Visual Studio 2010\Projects\WorkflowBuilder\seed.json" to "bin\Debug\seed.json".

CopyFilesToOutputDirectory:

  Copying file from "obj\Debug\GlobeTools.dll" to "bin\Debug\GlobeTools.dll".

  GlobeTools -> C:\Users\virtual\Documents\Visual Studio 2010\Projects\WorkflowBuilder\bin\Debug\GlobeTools.dll

  Copying file from "obj\Debug\GlobeTools.pdb" to "bin\Debug\GlobeTools.pdb".

PostBuildEvent:

  echo POSTBUILD

  POSTBUILD

PackageArcGISAddInContents:

  Removing directory "obj\Debug\esriAddIn\".

  Creating directory "obj\Debug\esriAddIn\Install".

  Copying file from "bin\Debug\Globe Tools Help.chm" to "obj\Debug\esriAddIn\Install\Globe Tools Help.chm".

  Copying file from "bin\Debug\GlobeTools.dll" to "obj\Debug\esriAddIn\Install\GlobeTools.dll".

  Copying file from "bin\Debug\GlobeTools.pdb" to "obj\Debug\esriAddIn\Install\GlobeTools.pdb".

  Copying file from "bin\Debug\ESRI.ArcGIS.Desktop.AddIns.dll" to "obj\Debug\esriAddIn\Install\ESRI.ArcGIS.Desktop.AddIns.dll".

  Copying file from "Config.esriaddinx" to "obj\Debug\esriAddIn\Config.esriaddinx".

  Successfully created Add-in "GlobeTools" ->  'C:\Users\virtual\Documents\Visual Studio 2010\Projects\WorkflowBuilder\bin\Debug\GlobeTools.esriAddIn'.

  esriRegAddin.exe "C:\Users\virtual\Documents\Visual Studio 2010\Projects\WorkflowBuilder\bin\Debug\GlobeTools.esriAddIn" /s

  Removing directory "obj\Debug\esriAddIn\".

  Creating directory "obj\Debug\esriAddIn\".

Build succeeded.

This looks like it might be useful, but it's not clear where in the project to add the Target tag. Alternatively, it might be possible to build the whole solution on the commandline, as in this post, then copy the addin when it has finished.

0 Kudos