Marko Apfel - Afghanistan/Belgium/Germany

Management, Architecture, Programming, QA, Coach, GIS, EAI

  Home  |   Contact  |   Syndication    |   Login
  187 Posts | 2 Stories | 201 Comments | 4 Trackbacks

News



Twitter | LinkedIn | Xing

Archives

Post Categories

Image Galleries

BizTalk

C#

Enterprise Library

SAP

SQL Server

Technologie

Since ArcGIS 10 during the Visual Studio build an additional target with the execution of a program named esriRegasm is called. Amongst other things this program adds  the COM-categories in the registry.

If you need to call this program outside a build at an own cmd-prompt you could often see some strange errors.

Having the right permissions

First at all you need administration permissions. This is for the registry-entries.

You could open an admin-cmd like:

  1. Win + R
  2. runas /user:<AdminUser> cmd

Attention: If you have a 64-bit system you must take the cmd.exe from %windir%\SysWOW64.
Then with “right mouse button” > “Run as administrator” you get the admin-cmd.

Otherwise this error is thrown (only if parameter /e is specified):

ESRIRegAsm::Register
  Command line: "C:\Projects\_Esri2011\Workshop\bin\EsriDE.Samples.ContentFinder.LegacyAgdAdapter.dll" /p:Desktop /e

  Registry Capture On.
  Registering managed library...
  Registry Capture Off.
  Processing Registry Entries...
  Created configuration file: {84afc21e-7c0f-4fa6-8aad-0c02ef35ea9f}_esride.samples.contentfinder.legacyagdadapter
  Copying configuration file to destination...

Operation Failed
00A49118

**********************************

Press Enter to continue...

and a message pops up:

Registration failed.

Could not write to disk.

Run esriRegasm

Go to the directory with the esriRegasm-program.
for instance: cd c:\Program Files (x86)\Common Files\ArcGIS\bin

Execute the program with the full assembly-name and option /p:Desktop
for instance: esriRegasm.exe "C:\Projects\_Esri2011\Workshop\bin\EsriDE.Samples.ContentFinder.LegacyAgdAdapter.dll" /p:Desktop

Run esriRegasm at a build or CI-server without ArcGIS-installation

For this scenario we copy the needed Esri-stuff to a folder beneath our project. In my case this folder is <project-root>\tools\Esri\

You need from “c:\Program Files (x86)\Common Files\ArcGIS\bin” the following files:

  • ESRIRegAsm.exe
  • ESRIRegAsm.exe.config
  • DADFLib.dll

Put your commands in a batch and run this batch as a build-step.

Update 2011/05/13

It seems, that the batch was a wrong hint.

One correct variant, is to change the ESRIRegAsm-calls in the *.scproj Files.

Originally there is (for new Addins):

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

<Target Name="AfterBuild">
    <Warning Text="Unable to create .esriAddin; missing ESRI ArcGIS Add-in SDK component(s)." Condition="!Exists('$(MSBuildExtensionsPath)\ESRI\ESRI.ArcGIS.AddIns.targets')" />
</Target>

or (for “old style” components):

<Target Name="BeforeClean">
    <Exec WorkingDirectory="$(CommonProgramFiles)\ArcGIS\bin" Command="esriRegasm.exe &quot;$(TargetPath)&quot; /p:Desktop /u /s" Condition="Exists('$(TargetPath)')" />
</Target>
<Target Name="AfterBuild">
    <Exec WorkingDirectory="$(CommonProgramFiles)\ArcGIS\bin" Command="esriRegasm.exe &quot;$(TargetPath)&quot; /p:Desktop /s" />
</Target>

and you should change this to:

<Target Name="BeforeClean">
    <Exec WorkingDirectory="$(SolutionDir)\.." Command="$(SolutionDir)\..\tools\Esri\esriRegasm.exe &quot;$(TargetPath)&quot; /p:Desktop /u /s" Condition="Exists('$(TargetPath)')" />
</Target>
  
<Target Name="AfterBuild">
    <Exec WorkingDirectory="$(SolutionDir)\.." Command="$(SolutionDir)\..\tools\Esri\esriRegasm.exe &quot;$(TargetPath)&quot; /p:Desktop /s" />
</Target>

BTW: maybe a own target frees you from the complex line in the *.csproj. Maybe I will investigate this later.

Update 2011/05/16

Okay – some things are stranger than first thought. This update ends up with a folder structure and project settings to run the stuff

First at all my folder-structure

part of src-folder:

part of tools-folder:

 

Next thing: we must edit the ESRI.ArcGIS.AddIns.targets file:

<!-- ORIGINAL ESRI -->
<!--
<Exec 
	IgnoreExitCode="true"
	Condition="!Exists('Dont_EsriRegAddin.txt') And Exists('$(AddInFileToBeDeployed)')"
	WorkingDirectory="$(CommonProgramFiles)\ArcGIS\bin"
	Command="esriRegAddin.exe &quot;$(AddInFileToBeDeployed)&quot; /s">
	<Output TaskParameter="ExitCode" PropertyName="ESRIRegAddinExitCode" />
</Exec>
-->
		
<!-- MARKO -->
<Exec 
	IgnoreExitCode="true"
	Condition="!Exists('Dont_EsriRegAddin.txt') And Exists('$(AddInFileToBeDeployed)')"
	WorkingDirectory="$(ProjectDir)\..\..\..\tools\Esri"
	Command="esriRegAddin.exe &quot;$(AddInFileToBeDeployed)&quot; /s">
	<Output TaskParameter="ExitCode" PropertyName="ESRIRegAddinExitCode" />
</Exec>
<!-- ORIGINAL ESRI -->
<!--
<Target Name="CleanArcGISAddin" Condition="Exists('$(ZipIntermediatePath)AddInID.txt')">

	<!- get addin id and run ESRIRegAddin /u ->
	<ReadLinesFromFile File="$(ZipIntermediatePath)AddInID.txt">
		<Output TaskParameter="Lines" PropertyName="AddInCleanID" />
	</ReadLinesFromFile>

	<Exec IgnoreExitCode="true" WorkingDirectory="$(CommonProgramFiles)\ArcGIS\bin" Command="esriRegAddin.exe &quot;$(AddInCleanID)&quot; /u /s" />
	<Delete Files="$(ZipIntermediatePath)AddInID.txt" />
</Target>
-->
	
<!-- MARKO -->
<Target Name="CleanArcGISAddin" Condition="Exists('$(ZipIntermediatePath)AddInID.txt')">

	<!-- get addin id and run ESRIRegAddin /u -->
	<ReadLinesFromFile File="$(ZipIntermediatePath)AddInID.txt">
		<Output TaskParameter="Lines" PropertyName="AddInCleanID" />
	</ReadLinesFromFile>

	<Exec 
		IgnoreExitCode="true"
		WorkingDirectory="$(ProjectDir)\..\..\..\tools\Esri"
		Command="esriRegAddin.exe &quot;$(AddInCleanID)&quot; /u /s" />
	<Delete Files="$(ZipIntermediatePath)AddInID.txt" />
</Target>

and also the *.csproj of the Add-in:

<!-- ORIGINAL ESRI -->
<!--
<Import Project="$(MSBuildExtensionsPath)\ESRI\ESRI.ArcGIS.AddIns.targets" Condition="Exists('$(MSBuildExtensionsPath)\ESRI\ESRI.ArcGIS.AddIns.targets')" />
-->
<!-- MARKO -->
<Import
	Project="$(ProjectDir)\..\..\..\tools\Esri\ESRI.ArcGIS.AddIns.targets"
	Condition="Exists('$(ProjectDir)\..\..\..\tools\Esri\ESRI.ArcGIS.AddIns.targets')" />
<Target Name="AfterBuild">
	<!-- ORIGINAL ESRI -->
	<!-- Gives build warning when add-in targets file is not found. -->
	<!--
	<Warning Text="Unable to create .esriAddin; missing ESRI ArcGIS Add-in SDK component(s)." Condition="!Exists('$(MSBuildExtensionsPath)\ESRI\ESRI.ArcGIS.AddIns.targets')" />
	-->

	<!-- MARKO -->
	<Warning
		Text="Unable to create .esriAddin; missing ESRI ArcGIS Add-in SDK component(s)."
		Condition="!Exists('$(ProjectDir)\..\..\..\tools\Esri\ESRI.ArcGIS.AddIns.targets')" />

</Target>

Here you could have a look at the stuff:

Democode for ESRI 2011 (Die Deutschsprachige  GIS-Konferenz)

posted on Tuesday, April 26, 2011 8:53 PM

Feedback

# re: Calling esriRegasm manually (outside an ArcGIS-installation) 5/4/2011 3:10 PM Lorenz Meyer
Hallo Marko

Das wäre eigentlich noch genau das was wir suchen. Ich habe das auch schon versucht, dieses ESRIRegAsm.exe standalone laufen zu lassen, leider ohne Erfolg. Die 3 Files (EsriRegAsm.exe, EsriRegAsm.exe.config und DADFLib.dll) reichen scheinbar nicht. Bei der Ausführung des EsriRegAsm.exe bekomme ich dann immer die folgende Meldung:
FATAL ERROR: Could not create ArcGIS Version Manager Component

Operation Failed
0012F348

Somit fehlt noch irgendwas...Hast du einen Tipp?

Danke und Gruss
Lorenz

# re: Calling esriRegasm manually (outside an ArcGIS-installation) 5/13/2011 10:03 AM Marko Apfel
Hallo Lorenz,

nach unserem gestrigen Mailverkehr, habe ich es nun im Kontext der Esri2011 nun selber noch ausprobiert. Den von dir beschriebenen Fehler hatte ich zwar nicht, dafür aber andere Fehler im Zusammenhang mit Jerkins.
Nach den Änderungen im o.g. Update läuft das soweit erstmal - auf meinem eigenen Rechner. Da dieser nicht ArcGIS-frei ist, könnte die von Andry schon angemerkte fehlende ESRI.ArcGIS.Version.dll das Problem bei euch sein.
Bin gespannt!

Viele Grüße
Marko

Post A Comment
Title:
Name:
Email:
Comment:
Verification: