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" ];
source share