Login to participate
Endpoint Management & Virtualization BlogsRSS

Using SOURCEDIR Property in Package

piyushnasa's picture

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.... :)

Eshwar's picture

Good to know this...

Quite interesting stuff dude. keep posting...

Thanks,
Eshwar

piyushnasa's picture

Thanks...

Thanks Parameswara.. I try to put in all the stuff which I feel will be useful for others. Thanks for appreciating. :)

Piyush Nasa
Altiris Certified Professional (ACP)

looeee's picture

A couple of things

You should only ever run ResolveSource at install-time by using the condition "not Installed" or the MSI will bounce the media unnecessarily. Your users don't want to have to find the CD at uninstall-time.

Also, I think the property that you should be using is the private property SourceDir

Here's a nice article on the ResolveSource action.

looeee

piyushnasa's picture

Can be used at uninstall time

I disagree with you when you say that it should only be used at install time. Hardly these days, the installations are pushed through CD's. It is generally through network drives which everyone has access to. Well almost, except the laptop users.
If it is made to be delivered in CD, then I agree with you.
If we are using SOURCEDIR at install time, then I am sure there would be a reason for that, like certain things cannot be copied to User's desktop maybe due to size of the source. If you need to call an xml file located in source which will be used by uninstall exe located in Source folder then I am sure in that case u will have to use SOURCEDIR property at uninstall too.

And about the MSDN article which you have mentioned, clearly states that" The ResolveSource action should not be executed when the source is unavailable, as it may be when uninstalling the application."
I cannot see a strong statement here. They are just suggesting that when the source is unavailable, then... but when you know that the source will be available then we can definitely use SOURCEDIR at uninstall time.

In a nutshell: Please don't make strong statements like "only ever", there might be situations which you are unaware of.

Hope this clarifies your doubt.

Piyush Nasa
Altiris Certified Professional (ACP)

Harsh's picture

SourceDir

Whatever commented by looeee is not wrong.I guess he supported your article with his comment. If ResolveSource actioned at the time of uninstallation then, it will ask for source location.

If you want to test this , disconnect your network drive or rename/delete the source folder from where you installed the application.
At the time of uninstallation your installer should not ask for source folder.

Private property SourceDir do not get resolve at the time of repair,so it will always ask for source location if we moved/renamed it or make it unavailable.

I hope I didn't make any STRONG statement in above comment. If yes then apologies.

Regards
Harsh

piyushnasa's picture

Chill Harsh...

Harsh, no you have not made any strong statements.. :D

I agree what he said was true, but i just did a package where we had to resolve the SOURCEDIR property at uninstall time due to some reasons.. The network drive is always connected here and we were assured of that. So saying something like "only ever" is too strong a statement to say.. I have faced and experienced something so I shared it here. It is not that whatever is written in MSDN, has to be always followed. Infact even they have kept a loop and an option as I mentioned in my last comment.

And i did use public property SOURCEDIR and not private. And thanks for your input on this.. I didn't know this..

Piyush Nasa
Altiris Certified Professional (ACP)