Search code examples
c#wixguidetw-eventsource

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 ?


Solution

  • 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>