views:

56

answers:

2

What is the purpose of the Source attribute? Have a look at this snippet:

<Component Id="MyComponent" Guid="123456789-abcd-defa-1234-DCEA-01234567890A">
          <File Id="myFile" Name="myFile.dll" Source="myFile.dll"/>
</Component>

Since Name and Source have the same value, what does Source add? The code does not compile without it.

Where can I find documentation that explains these attributes? I have tried MSDN for MSI but did not find an answer.

Thanks.

+2  A: 

WiX and MSI are not the same. Hence no reference in the MSDN documentation ;)

You need to refer to WiX.CHM where you installed WiX, or the online WiX documentation.

Assuming you're talking about File/@Name and File/@Source, this is optional if your source files are laid out in the same way as your WiX directory structure.

The nifty part comes in when you use multiple -b arguments to light and SourceDir in the File/@Source attribute. For example...

<File Id="example.dll" KeyPath="yes" Source="SourceDir\example.dll" DefaultLanguage="0" />

I usually specify 4 folders with -b in my standard build. One for various installer specfiic resources, one for where I store merge modules, one for common resources between all my installs and one for my source files. Now WiX will look in every directory specified on the command line, which makes things a lot more portable if I'm building on a different system with a different directory layout.

As per the documentation, if (in your example) myfile.dll was in the current directory, you could omit the File/@Source attribute.

sascha
+1  A: 

File/@Source provides the location to get information about the file (size, language, hash) and to copy it to the correct location (either in a cabinet or laid out in a directory relative to the MSI file).

File/@Name is optional if you do not want to install the file with a different name. In other words, if the file exists with the right name on your build machine, just refer to it using the File/@Source and leave off File/@Name.

File/@Id is also optional as long your file name is unique. You cannot have two files with the same File/@Id so add File/@Id when you have collisions.

In WiX v3.5 I often just do:

<Component> <File Source="my.exe"/> </Component>

Rob Mensching