SOLUTION:
There is an environment variable called
SOURCEDIR which stores the path of the directory from which the msi or the setup.exe is running or has been launched.
You should follow the following steps to set and get the value of this variable:
1) Go to your Visual Studio Set Up project and right click. Select 'View'->'Custom Actions'.
2) On 'Custom actions' screen, you would see the various steps listed as 'Install', 'Commit', 'Rollback', 'Uninstall' etc. Click the '+' sign beside the 'Install' action and you would see an entry like 'Primary output from YOUR_SERVICE_NAME (Active)'. Right-click on this entry and select 'Properties window'.
3) Now add the following entry in 'CustomActionData' field:
/sourcedir="[SOURCEDIR]\"If there are other entries also mentioned in your 'CustomActionData' field, then do not forget to place a space(blank) between this and other entries.
4) Now you can access this value using the following code in your custome action code:
string sourceDirectory = this.Context.Parameters["sourcedir"]; That's it. You are Done!!
Note:
If you looking to add a custom action screen in your visual studio set up(installer) project, the you can
read the steps here.