4

As mentioned in the element's documentation, the default value for the ID attribute is the file name portion from the Source attribute.

The problem occurs when we add multiple files with the same name (but different locations), thus the ID attributes that should be unique become a duplication.

Is there an easy way to give the attribute a random identifier (something like the asterisk in the GUID of the Product element)?

I want not to set the identifiers manually since the files with the same name increase and spread in many .wxs files all over the project.

How about the option of making a WiX extension for that? Something like a function call to get random values.

Thank you!

Stein Åsmul
  • 39,960
  • 25
  • 91
  • 164
Reflection
  • 1,936
  • 3
  • 21
  • 39
  • I thought this was in place already? If it is not there you should add a feature request. – Stein Åsmul Aug 26 '14 at 13:23
  • What way to put a random identifier you think that is there? An asterisk? A function to make random values? Currently there is a default value that performs a different operation, however. – Reflection Aug 26 '14 at 13:27
  • Remove the whole Id field and see if this creates the identifier for you. See [**this answer**](http://stackoverflow.com/a/24769965/129130) for a similar issue. All you need for a file is the Source attribute. – Stein Åsmul Aug 26 '14 at 13:36
  • Yes, it creates the identifiers, but for FolderA\File.txt and FolderB\File.txt it is the same ("File"). The explanation for the default identifier value is in the documentation. – Reflection Aug 26 '14 at 13:39
  • 1
    I am not currently using Wix every day, but I thought that feature was in place already. I suppose you could try **heat.exe** and see if it has the same problem behavior. It might have switches to allow auto-generated guids or reveal a syntax that does that automatically. – Stein Åsmul Aug 26 '14 at 14:24
  • Yep, heat.exe generates unique identifiers. However, what about if I don't want to harvest and thus to use it? – Reflection Aug 26 '14 at 19:27
  • 1
    I guess this means that the file ID generation can be hooked up to the same code in heat that creates the unique identifier. This is no doubt a known Wix issue, and only the core team can tell you if it will be included. I can't see any reason not to auto-generate a unique Id. – Stein Åsmul Aug 27 '14 at 00:47
  • I added a feature request. By the way, the function used in Heat.exe to generate unique identifiers is Common.GenerateIdentifier, from their GitHub. – Reflection Aug 30 '14 at 15:37
  • Great, lets hear what Rob and Bob say. I suppose there might be a good reason why this isn't already done, but I can't see it. – Stein Åsmul Aug 30 '14 at 15:40
  • http://stackoverflow.com/questions/19255763/wix-heat-replace-an-autogenerated-guid-with-known-string-using-xslt You could possibly use this technique to prefix or replace part of the guid with a hash on the path. – Novaterata Sep 06 '14 at 19:26

1 Answers1

-2

In WiX Toolset v3.7, the Ids get automatically generated. This will work most of the time (still an issue when 2 filenames are similar e.g. when the only difference is a blank in one file and an '_' at the same position within the filename in the other)