PGDB: include into deployment package

723
4
04-27-2011 11:33 AM
JamesCrandall
MVP Frequent Contributor
Is there a specific method or process to distribute a Personal Geodatabase with a Setup.exe or Installer.msi?  I'd like to distribute a PGDB that my extension uses with the .msi that is built for deploying the assembly.

Are there any specific suggestions on AppPath settings?  For example, I have some code that opens an IFeatureWorkspace of that PGDB:

pWorkspaceFactory.OpenFromFile(db_path & "\Reporting.mdb", 0)



I guess my question on AppPath would be where exactly would the Installer set AppPath?

Edit: here is my current GetAppPath function:


Private Shared Function GetAppPath() As String
        Dim path As String

        path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly.Location)
               Return path
    End Function
0 Kudos
4 Replies
NeilClemmons
Regular Contributor III
We do this all the time.  The installer copies the geodatabase and the application assembly to a specific location relative to the installation directory that the user chooses during the installation wizard.  For instance, the application assembly is copied to ...\GISi\OurApplication and the geodatabase is copied to ...\GISi\OurApplication\Data.  Our code uses System.Reflection.Assembly.GetExecutingAssembly.Location to get the location of the assembly then uses this path to build the path to the geodatabase.  In this case it would look like this:

dbasePath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly.Location) & "\Data\ourDatabase.mdb"

The relative path of the database to the assembly is always the same.  The only thing that changes is the root directory where the user chooses to install the application.  You can also just have the installer create a registry entry that contains the path to the database and have your code read the path from that registry key.
0 Kudos
JamesCrandall
MVP Frequent Contributor
Neil, Thanks a bunch for the input.  I think I am heading down the right path here, but could you clarify how you include the PGDB in the .msi package?  That is, do I just add the PGDB (.mdb) file to the Project?  How do I tell it where to install/place this file? 

Also, this:

WeThe only thing that changes is the root directory where the user chooses to install the application.  You can also just have the installer create a registry entry that contains the path to the database and have your code read the path from that registry key.


Do you have an example or walkthru on how to accomplish this?  How


Thank You!!!
0 Kudos
NeilClemmons
Regular Contributor III
It depends on what you're using to create your installer.  Using the standard Visual Studio deployment project you just open the File System view and add the file to the correct folder.  You can create a registry entry on the Registry view and set its value using [TARGETDIR] plus the rest of the path to the database (i.e. [TARGETDIR]\Data\ourDatabase.mdb).
0 Kudos
JamesCrandall
MVP Frequent Contributor
It depends on what you're using to create your installer.  Using the standard Visual Studio deployment project you just open the File System view and add the file to the correct folder.  You can create a registry entry on the Registry view and set its value using [TARGETDIR] plus the rest of the path to the database (i.e. [TARGETDIR]\Data\ourDatabase.mdb).


Yep.  That's it!

Much appreciated!
0 Kudos