A.Pissicat
A.Pissicat

Reputation: 3275

C# Wix Service installer - Unresolved reference to symbol

I crated a service in C# with Viwual Studio 2017.

Now I'm trying to create an installer with Wix. It's not my first time with wix, but this time I can't build my setup. I have error :

Unresolved reference to symbol 'Component:InstallComponents' in section 'Product:*'.

I saw some topic about this, but it did not solve my problem.

There is my product.wxs :

<?xml version="1.0" encoding="UTF-8"?>
<?define compagny = "myCompagny"?>
<?define product = "Service Name"?>
<?define service = "MyService"?>
<?define version = "!(bind.FileVersion.MyService.exe)"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Product Id="*" 
           Name="$(var.product)"
           Language="1033"
           Version="$(var.version)"
           Manufacturer="$(var.compagny)" 
           UpgradeCode="XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX">
        <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" InstallPrivileges="elevated"/>
        <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
        <Media Id="1" Cabinet="MyService.cab" EmbedCab="yes" />

        <Directory Id="TARGETDIR" Name="SourceDir">
            <Directory Id="ProgramFilesFolder">
        <Directory Id="CGYFOLDER" Name="$(var.compagny)">
          <Directory Id="INSTALLFOLDER" Name="$(var.product)" />
        </Directory>
            </Directory>
        </Directory>

    <ComponentGroup Id="InstallComponents">
      <Component Id="InstallService" Guid="XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX" Directory="INSTALLFOLDER">
        <File Id="MyService.exe.config"
              Name="$(var.service).exe.config"
              Source="$(var.MyService.TargetDir)\$(var.service).exe.config"
              Vital="yes"/>
        <RemoveFile Id="ALLFILES" Name="*.*" On="both" />
        <ServiceInstall Id="ServiceInstaller"
                        Type="ownProcess"
                        Vital="yes"
                        Name="$(var.service)"
                        DisplayName="$(var.product)"
                        Description=""
                        Start="auto"
                        Account="LocalSystem"
                        ErrorControl="normal" />
        <ServiceControl Id="Service_Start" Name="MyService" Start="install" Wait="no" />
        <ServiceControl Id="Service_Stop" Name="MyService"  Stop="both" Remove="uninstall" Wait="yes" />
      </Component>
    </ComponentGroup>

    <!-- Tell WiX to install the files -->
    <Feature Id="ProductFeature" Title="$(var.product)" Level="1">
      <ComponentRef Id="InstallComponents" />
    </Feature>
    </Product>
</Wix>

InstallComponents exists in ComponentGroup, I don't understand why I have this error.

Upvotes: 1

Views: 1428

Answers (1)

A.Pissicat
A.Pissicat

Reputation: 3275

The mistake was in my Feature.

My InstallComponents is define as ComponentGroup, so to install it, my feature must be like this :

<Feature Id="ProductFeature" Title="$(var.product)" Level="1">
  <ComponentGroupRef Id="InstallComponents" />
</Feature>

Upvotes: 0

Related Questions