In WiX files, what does Name=“SourceDir” refer to?

前端 未结 3 1485
野趣味
野趣味 2020-11-29 22:39

WiX files always seem to include this line:


What is \"SourceDir\"? What is it used fo

相关标签:
3条回答
  • 2020-11-29 23:16

    From: http://robmensching.com/blog/posts/2010/1/26/StackOverflow-what-does-NameSourceDir-refer-to

    Honestly, it's something that we should have hidden from the developer 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.

    0 讨论(0)
  • 2020-11-29 23:18

    None of this was really helpful for me. I found this thread wondering how to make a Debug build, where my source files (the ones going in the installer) could be pulled from either the "Release" build dir or the "Debug" build dir of the project I am trying to make an installer for.

    After some grepping, I found the actual path in the wixproj file, there SourceDir is defined as:

    <SourceDir>$(SolutionDir)distribution\Release</SourceDir>
    

    which has really nothing to do with installation files and project files. I was able to add another PropertyGroup that mirrored the release group which now pointed to my debug files:

    <SourceDir>$(SolutionDir)distribution\Debug</SourceDir>
    

    Hope this helps someone. I know it's a little off topic, but hopefully it helps someone in the future. Not sure why the project plug-in does not expose this value? Or am I missing that?

    0 讨论(0)
  • 2020-11-29 23:26

    From the wix.chm documentation, topic "How To: Add a File To Your Installer":

    The element with the id TARGETDIR is required by the Windows Installer and is the root of all directory structures for your installation

    According to the MSDN documentation TARGETDIR is

    the root destination directory for the installation

    Also according to MSDN, SourceDir is

    the root directory that contains the source cabinet file or the source file tree of the installation package

    So the SourceDir property points to a real directory: the one where your MSI file sits. You can see this in the installer log when installing with msiexec /lvx* installer.log installer.msi.

    However, for some reason SourceDir is completely ignored when resolving the TARGETDIR. The TARGETDIR must be either set explicitly (e.g. on the command line) or else it resolves to ROOTDRIVE. If ROOTDRIVE is not explicitly set then it is the root of the drive with the most free space.

    A quick test shows that installing a component to TARGETDIR indeed puts the files at the root of my D:\ drive, instead of the folder where the MSI sits.

    0 讨论(0)
提交回复
热议问题