Guids are generated not by the pre-processor but much later by light.exe. * Guids are derived from the component keypaths which are all the same in the generated code.
There are a couple of posts on this list stating that foreach was supposedly deprecated: there are some problems associated with generating components. Generating multiple guids for the same file can be dangerous. You'll end up with different guids attached to the same file through different components. Thats a violation of the component rules *unless* you can guarantee only one of the components is ever going to be installed on a particular machine (all conditions are mutually exclusive). Not having consistent guids from build to build is also a possible source of problems. If youre aware of all the pitfalls and can be sure they won't affect you now or in all your servicing scenarios (upgrades and patches), you should be able to accomplish your aim by including a registry value in each component with the keypath set to yes and whose path includes the loop index variable. This would ensure each generated guid is consistent between builds and unique. It will be hard to patch since the keypath isn't the file and a registry path doesn't have a version or file hash. If it was me and the number of components isn't too large and doesn't change often, Id hard code them all. That way, when you want a change, you have to do it deliberately and you're less likely to be caught by surprise. -----Original Message----- From: Pound, Robert (CDC/OCOO/ITSO) (CTR) [mailto:u...@cdc.gov] Sent: 30 December 2010 13:51 To: wix-users@lists.sourceforge.net Subject: [WiX-users] Creating Unique GUIDs inside a foreach block? I'm using VS2010, WiX version 3.6.1112.0. The following snippet of code is used to generate a 1-n # of components, based upon value of EnvironmentList variable. It works ok with 1 entry in EnvironmentList. However when EnvironmentList contains 2 or more entries I get an ICE08 error on the component stating that it has a duplicate GUID. It seems that the Guid="*" is not creating a new GUID on each iteration of the foreach loop by the preprocessor. In this scenario, how can I generate a unique GUID for use within a foreach loop? <?foreach ENVIRONMENT in $(var.ENVIRONMENTList)?> <Component Id="InstallConfig.$(var.ENVIRONMENT)" Guid="*"> <Condition><![CDATA[USENVIRONMENTCONFIGFILE = "yes" AND PROP.INSTALL.ENVIRONMENT = "$(var.ENVIRONMENT)"]]></Condition> <File Id='file.config.$(var.ENVIRONMENT)' Name='web.config' Source="$(var.SourceDir)web.config.$(var.ENVIRONMENT)" DiskId='1'/> </Component > <?endforeach?> Thanks, Bob ------------------------------------------------------------------------ ------ Learn how Oracle Real Application Clusters (RAC) One Node allows customers to consolidate database storage, standardize their database environment, and, should the need arise, upgrade to a full multi-node Oracle RAC database without downtime or disruption http://p.sf.net/sfu/oracle-sfdevnl _______________________________________________ WiX-users mailing list WiX-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wix-users SDL PLC confidential, all rights reserved. If you are not the intended recipient of this mail SDL requests and requires that you delete it without acting upon or copying any of its contents, and we further request that you advise us. SDL PLC is a public limited company registered in England and Wales. Registered number: 02675207. Registered address: Globe House, Clivemont Road, Maidenhead, Berkshire SL6 7DY, UK. ------------------------------------------------------------------------------ Learn how Oracle Real Application Clusters (RAC) One Node allows customers to consolidate database storage, standardize their database environment, and, should the need arise, upgrade to a full multi-node Oracle RAC database without downtime or disruption http://p.sf.net/sfu/oracle-sfdevnl _______________________________________________ WiX-users mailing list WiX-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wix-users