Gaël
Gaël

Reputation: 137

Wix - Add a Component with/without GUID in a ComponentGroup

Having a bug occurring through the windows log when my application want to exit, I need to add in my installer an EventSource defining an EventMessageFile which will be the Event log message file of the .NET Framework (I am following that solution : https://stackoverflow.com/a/574055/6617804).

In my Component.wxs, I add the Component of Id LogsNet in this ComponentGroup LogsComponents :

<ComponentGroup Id="LogsComponents" Directory="LogsFolder">
  <Component Id="Logs" Guid="{339873E0-0984-4A1B-8C53-0F64DFAD56BC}">
    <File Id="..." Source="..." />
    <File Id="..." Source="..." />
    <File Id="..." Source="..." />
    <File Id="..." Source="..." />
    <RemoveFolder Id='LogsFolder' On='uninstall' />
    <RegistryValue Root='HKCU'
                       Key='Software\[Manufacturer]\[ProductName]'
                       Type='string'
                       Value=''
                       KeyPath='yes' />
  </Component>

  <Component Id="LogsNET" >
    <util:EventSource
       Log="Application" Name="ROOT Builder"
       EventMessageFile="%SystemRoot%\Microsoft.NET\Framework\v2.0.50727\EventLogMessages.dll"/>
  </Component>
</ComponentGroup>

When I try to add it that way (without generating a GUID), it brings about that error :

The Component/@Guid attribute's value '*' is not valid for this component because it does not meet the criteria for having an automatically generated guid. Components using a Directory as a KeyPath or containing ODBCDataSource child elements cannot use an automatically generated guid. Make sure your component doesn't have a Directory as the KeyPath and move any ODBCDataSource child elements to components with explicit component guids. OptifuelInfomax_Installer (OptifuelInfomax_Installer\OptifuelInfomax_Installer) C:\Source\Infomax\OptiFuelInfomax\OptifuelInfomax_Installer\Components.wxs 80

And when I generate a GUID with Visual Studio in Tools -> Create GUID (Registry Format), it says in the error list :

The Component element contains an unexpected attribute 'GUID'. OptifuelInfomax_Installer (OptifuelInfomax_Installer\OptifuelInfomax_Installer) C:\Source\Infomax\OptiFuelInfomax\OptifuelInfomax_Installer\Components.wxs 80

And it also says in the IDE : The 'GUID' attribute is not allowed.

Am I supposed to use a GUID for that Component ?

Upvotes: 0

Views: 1552

Answers (2)

Stein &#197;smul
Stein &#197;smul

Reputation: 42136

One more thing, I will add this as an answer to get in the links and the disclaimers:

I haven't done much EventMessageFile installation, but I just want to add that hard coded paths are always wrong (your use of %SystemRoot% would probably still work). As you no doubt know, it is not uncommon for the system partition to be something other than C:\. Please see this particular answer (it is a particular answer from the "thread" you have linked to yourself) for how to eliminate your hard coded paths: How do you create an event log source using WiX.

Also, here is the documentation for the built-in WiX .NET properties: WixNetfxExtension (a bit down the page). I would also recommend you install using one file per component. Certainly do not install multiple binaries in the same component - this is a violation of the component rules. And a Symantec article on component rules as well.

Upvotes: 1

Ga&#235;l
Ga&#235;l

Reputation: 137

It is saying "The 'GUID' attribute is not allowed" simply because it does not recognize the attribute 'GUID' - it is case sensitive ; the real attribute name is 'Guid' and so it is compiling with :

<Component Id="LogsNET" Guid ="{...blah123...}">
    <util:EventSource
       Log="Application" Name="ROOT Builder"
       EventMessageFile="%SystemRoot%\Microsoft.NET\Framework\v2.0.50727\EventLogMessages.dll"
       KeyPath="yes"/>
  </Component>

Upvotes: 0

Related Questions