PDA

View Full Version : Component / file best practice?



plokolp
05-09-2008, 05:34 AM
Hi fellow installers,

I'm looking for information about how to best organize files and components.

It seems that you can organize features into components. This makes a lot of sense. However, it seems that you can also create components than contain many files. Furthermore, every time you add a file to a project, they are converted into individual components.

So my question...

1. Is it better to keep every file as a separate component and then add them to features, or

2. Is it better to arrange each file that belongs to a feature into a corresponding component and then add them as a feature?

Thanks,

Rod

jassing
05-09-2008, 10:09 AM
It depends on the project, the desired results, and how you want to present things to your end user. I don't design my installers all the same, they are all different based on the needs they present.

Lorne
05-09-2008, 10:31 AM
That is actually a really good question, and one that the Windows Installer community has been debating for a long time.

The general consensus is that it's better to have every file in its own component, to avoid issues in the long run. Although this is considered the best practice in the WiX community, it isn't always followed, simply because of the labour involved in writing all the XML for so many components, and keeping track of all the component IDs and GUIDs by hand. MSI Factory removes this burden from the user by generating the component IDs and GUIDs automatically to make the best practice possible.

Even so, having one component per file can make the list of components in the Component Editor more daunting...which is something we plan to make easier in the future with improvements to the component interface.

We've thought of providing more control over how MSI Factory organizes components, so you could set it to automatically group specific file types within the same folder, for example; but there are some hidden risks involved.

Although having fewer components can make a project easier to work with, you must be careful not to break any of the (very important) MSI component rules. For example, you can't add or remove items from a component once it's deployed -- if you do, you need to change the component GUID and ID (i.e. create a new component) and you're also supposed to change the names and/or locations of all the resources in the component.

See:

Changing the Component Code (http://msdn.microsoft.com/en-us/library/aa367849(VS.85).aspx)

Organizing Applications into Components (http://msdn.microsoft.com/en-us/library/aa370561(VS.85).aspx)

Note that some things must be put in the same component; for example, shortcuts should be in the same component as the file they point to.