Search code examples
wixwix4

How to fix wix v4 build not finding extension


I'm using the util extension in my Wix project to get the util:ServiceConfig element.

I get the following build error:

SampleFirst.wxs(61): error WIX0200: The ServiceInstall element contains an unhandled extension element 'ServiceConfig'. Please ensure that the extension for elements in the 'http://wixtoolset.org/schemas/v4/wxs/Util' namespace has been provided.

The source code is taken from a sample found on the FireGiant site, in the tutorial here . The sample builds successfully before my changes. My only changes are adding the ServiceInstall to one of the components and references to the extensions in the project file.

SampleFirst.wxs file:

<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"
    xmlns:util="http://wixtoolset.org/schemas/v4/wxs/Util"
    xmlns:netfx="http://wixtoolset.org/schemas/v4/wxs/netfx">

  <Package Name="Foobar 1.0" UpgradeCode="00CDD5C2-F827-4387-92E9-2772F1D660A5" Language="1033" Codepage="1252" Version="1.0.0" Manufacturer="Acme Ltd." InstallerVersion="100" ProductCode="36B7A7ED-4D92-4F4D-BE3C-BE9AC4ACDF96"><SummaryInformation Keywords="Installer" Description="Acme's Foobar 1.0 Installer" Manufacturer="Acme Ltd." />

    <Media Id="1" Cabinet="Sample.cab" EmbedCab="yes" DiskPrompt="CD-ROM #1" />
    <Property Id="DiskPrompt" Value="Acme's Foobar 1.0 Installation [1]" />

    

    <Feature Id="Complete" Level="1">
      <ComponentRef Id="MainExecutable" />
      <ComponentRef Id="HelperLibrary" />
      <ComponentRef Id="Manual" />
      <ComponentRef Id="ProgramMenuDir" />
    </Feature>

    <Icon Id="Foobar10.exe" SourceFile="FoobarAppl10.exe" />

  
      <StandardDirectory Id="ProgramFilesFolder">
        <Directory Id="Acme" Name="Acme">
          <Directory Id="INSTALLDIR" Name="Foobar 1.0">

            <Component Id="MainExecutable" Guid="5D93BCA5-1086-4802-809E-4FE60363CA31">
              <File Id="FoobarEXE" Name="FoobarAppl10.exe" DiskId="1" Source="FoobarAppl10.exe" KeyPath="yes">
                <Shortcut Id="startmenuFoobar10" Directory="ProgramMenuDir" Name="Foobar 1.0" WorkingDirectory="INSTALLDIR" Icon="Foobar10.exe" IconIndex="0" Advertise="yes" />
                <Shortcut Id="desktopFoobar10" Directory="DesktopFolder" Name="Foobar 1.0" WorkingDirectory="INSTALLDIR" Icon="Foobar10.exe" IconIndex="0" Advertise="yes" />
              </File>
            </Component>

            <Component Id="HelperLibrary" Guid="173FE012-0F1C-45A6-BC79-BBFB363B45F9">
              <File Id="HelperDLL" Name="Helper.dll" DiskId="1" Source="Helper.dll" KeyPath="yes" />
            </Component>

            <Component Id="Manual" Guid="B92B5ED5-FB38-4632-8FF0-CD1B37D9E67D">
              <File Id="Manual" Name="Manual.pdf" DiskId="1" Source="Manual.pdf" KeyPath="yes">
                <Shortcut Id="startmenuManual" Directory="ProgramMenuDir" Name="Instruction Manual" Advertise="yes" />
              </File>
            </Component>

          </Directory>
        </Directory>
      </StandardDirectory>

      <StandardDirectory Id="ProgramMenuFolder">
        <Directory Id="ProgramMenuDir" Name="Foobar 1.0">
          <Component Id="ProgramMenuDir" Guid="6B7F1E7C-01F6-4936-A107-BD75D8C3814F">
            <RemoveFolder Id="ProgramMenuDir" On="uninstall" />
            <RegistryValue Root="HKCU" Key="Software\[Manufacturer]\[ProductName]" Type="string" Value="" KeyPath="yes" />
            <ServiceInstall
              Id="FooServiceInstaller"
              Type="ownProcess"
              Name="fooservice"
              DisplayName="Foo Service"
              Description="Foo Service"
              Interactive="no"
              Start="auto"
              ErrorControl="ignore" >
              <util:ServiceConfig
                FirstFailureActionType="restart"
                SecondFailureActionType="restart"
                ThirdFailureActionType="restart"
                RestartServiceDelayInSeconds="1" />
            </ServiceInstall>

          </Component>
        </Directory>
      </StandardDirectory>

      <StandardDirectory Id="DesktopFolder" />
    </Package>
</Wix>

The project file wix_example.wixproj:

<Project Sdk="WixToolset.Sdk/4.0.1" ToolsVersion="4.0">
  <ItemGroup>
    <PackageReference Include="WixToolset.Netfx.wixext" Version="4.0.1" />
    <PackageReference Include="WixToolset.Util.wixext" Version="4.0.1" />
  </ItemGroup>
</Project>

I added the util extension with dotnet command:

dotnet add wix_example.wixproj package WixToolset.Util.wixext --version 4.0.1

I built my project from command line as follows:

msbuild wix_example.wixproj

Solution

  • The namespace is http://wixtoolset.org/schemas/v4/wxs/util, not http://wixtoolset.org/schemas/v4/wxs/Util.

    The doc is at https://wixtoolset.org/docs/schema/util/.