StackOverflow: what does Name=“SourceDir” refer to?

Honestly, the TARGETDIR/SourceDir Directory element is something that we should have hidden from the developer using the WiX toolset but didn't. Sorry. The truth of the matter is that the Windows Installer expects the Directory tree to always be rooted in a Directory row where the primary key (Directory/@Id) is "TARGETDIR" and the DefaultDir column (Directory/@Name) is "SourceDir".

During an install, TARGETDIR will default to the largest drive on the machine. SourceDir will be set to the location where the MSI is being executed. Now, SourceDir is tricky after the initial install because it won't be set unless the ResolveSource action is called. However, you don't want to explicitly call the ResolveSource action because it is likely to prompt you to provide the original source media (aka: insert the CD, please).

What we should have done in the WiX toolset is remove the need to specify the TARGETDIR/SourceDir pair and say "Any Directory element that has no parent will automatically be parented to TARGETDIR because that's what the MSI SDK says to do." Instead, you have to do it yourself... and some devs wonder what it all means.

Maybe we'll fix this in WiX v4.0.

From the StackOverflow question: http://stackoverflow.com/questions/1641094/in-wix-files-what-does-namesourcedir-refer-to

 

2 Comments

Comment by Shradha Jain on Wednesday, March 17, 2010 10:58 PM

i am still confused in targetdir, Sourcedir and installdir. Can u please give any example to explain clearly what is all the three if u install an application?

Comment by Oliver Critchley on Friday, June 10, 2011 7:32 AM

Hi Rob,

You say:
"SourceDir is tricky after the initial install because it won't be set unless the ResolveSource action is called. However, you don't want to explicitly call the ResolveSource action because it is likely to prompt you to provide the original source media."

I am a bit puzzled by this. Everyone tells me that scheduling ResolveSource is bad, because it can cause unwanted prompts for the original media during maintenance mode. But it appears that WiX (and Windows Installer too?) insist that I use the SourceDir property in the root of my target directory tree. Does this mean that prompts for the original media are unavoidable, or aren't things as bad as they look?

Thanks!

Leave a comment
optional