Monday, October 13, 2008

Using SOURCEDIR Property in Package

SOURCEDIR property in MSI package refers to the location from where the MSI is installed in the machine. How do we use this property in our package.

If you want to use a file which is kept in the source folder (next to where your MSI is placed), through Custom Action then you need to follow this procedure.

The SOURCEDIR cannot be directly used in the package. If you read the logs then SOURCEDIR property is created and correctly pointed to the directory. But later the log shows that: Deleting SOURCEDIR... So the value of this property is deleted and the MSI does not get access to it. If you display message with [SOURCEDIR] property then it will be empty.

The work around for this is that we can put an Action in the sequence called: "ResolveSource" after CostFinalize action. Then if you place your Custom Action after this action which refers to SOURCEDIR property then you will get the correct value of SOURCEDIR.

Acknowledgement: I would like to thank my friend, Anurag, here who helped me to figure this out.... :)

2 comments:

Anonymous said...

how to address this for Installers being developed by VS 2008.

Anonymous said...

The drawback to adding the ResolveSource action however, is that if the source is no longer available in that location, then the user is presented with a dialog asking them to point to the source location. It is a best practice to reduce the dependency on the original source. http://msdn.microsoft.com/en-us/library/windows/desktop/bb204770%28v=vs.85%29.aspx#reduce_update_sources