Install a directory from deployment projects

I am developing an application and I am going to deploy it using a deployment project (which the installer will create).

At one stage of the installation, the installer will be able to change the installation folder for the application.

I need to know what this folder is, because some files that I need to use from another DLL file will be saved there. How can I programmatically get this installation folder?

Thanks!

+4
source share
2 answers

Take a look at the Installer class. Add a new class derived from this class to your application project. Remember to apply the RunInstaller attribute.

In your deployment project, add a custom action to install and commit. For the CustomActionData property for the custom Set action, enter /Targetdir="[TARGETDIR]\" .

In your installer class that you created in the application project, override the installation method, and in this method you can get the installation directory as follows:

 string targetDir = Context.Parameters[ "TargetDir" ]; 
+6
source

If you have a really simple setup where the current build is installed in the main TARGETDIR, you can use:

 String targetDir = new System.IO.FileInfo(GetType().Assembly.Location).DirectoryName; 
0
source

All Articles