如何修复Wix V4构建未找到扩展。

huangapple go评论55阅读模式
英文:

How to fix wix v4 build not finding extension

问题

我在我的Wix项目中使用了util扩展来获取util:ServiceConfig元素。

我收到以下的构建错误:

SampleFirst.wxs(61): error WIX0200: ServiceInstall元素包含一个未处理的扩展元素'ServiceConfig'。请确保已提供'http://wixtoolset.org/schemas/v4/wxs/Util'命名空间中元素的扩展。

源代码取自FireGiant网站上的一个示例,在这里的教程1中可以找到。在我进行更改之前,示例可以成功构建。我唯一的更改是将ServiceInstall添加到一个组件中,并在项目文件中引用了扩展。

SampleFirst.wxs文件:

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

项目文件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>

我使用dotnet命令添加了util扩展:

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

我使用以下命令行构建了我的项目:

msbuild wix_example.wixproj

<details>
<summary>英文:</summary>
I&#39;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 &#39;ServiceConfig&#39;. Please ensure that the extension for elements in the &#39;http://wixtoolset.org/schemas/v4/wxs/Util&#39; namespace has been provided.
The source code is taken from a sample found on the FireGiant site, in the tutorial [here][1] . 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:
&lt;Wix xmlns=&quot;http://wixtoolset.org/schemas/v4/wxs&quot;
xmlns:util=&quot;http://wixtoolset.org/schemas/v4/wxs/Util&quot;
xmlns:netfx=&quot;http://wixtoolset.org/schemas/v4/wxs/netfx&quot;&gt;
&lt;Package Name=&quot;Foobar 1.0&quot; UpgradeCode=&quot;00CDD5C2-F827-4387-92E9-2772F1D660A5&quot; Language=&quot;1033&quot; Codepage=&quot;1252&quot; Version=&quot;1.0.0&quot; Manufacturer=&quot;Acme Ltd.&quot; InstallerVersion=&quot;100&quot; ProductCode=&quot;36B7A7ED-4D92-4F4D-BE3C-BE9AC4ACDF96&quot;&gt;&lt;SummaryInformation Keywords=&quot;Installer&quot; Description=&quot;Acme&#39;s Foobar 1.0 Installer&quot; Manufacturer=&quot;Acme Ltd.&quot; /&gt;
&lt;Media Id=&quot;1&quot; Cabinet=&quot;Sample.cab&quot; EmbedCab=&quot;yes&quot; DiskPrompt=&quot;CD-ROM #1&quot; /&gt;
&lt;Property Id=&quot;DiskPrompt&quot; Value=&quot;Acme&#39;s Foobar 1.0 Installation [1]&quot; /&gt;
&lt;Feature Id=&quot;Complete&quot; Level=&quot;1&quot;&gt;
&lt;ComponentRef Id=&quot;MainExecutable&quot; /&gt;
&lt;ComponentRef Id=&quot;HelperLibrary&quot; /&gt;
&lt;ComponentRef Id=&quot;Manual&quot; /&gt;
&lt;ComponentRef Id=&quot;ProgramMenuDir&quot; /&gt;
&lt;/Feature&gt;
&lt;Icon Id=&quot;Foobar10.exe&quot; SourceFile=&quot;FoobarAppl10.exe&quot; /&gt;
&lt;StandardDirectory Id=&quot;ProgramFilesFolder&quot;&gt;
&lt;Directory Id=&quot;Acme&quot; Name=&quot;Acme&quot;&gt;
&lt;Directory Id=&quot;INSTALLDIR&quot; Name=&quot;Foobar 1.0&quot;&gt;
&lt;Component Id=&quot;MainExecutable&quot; Guid=&quot;5D93BCA5-1086-4802-809E-4FE60363CA31&quot;&gt;
&lt;File Id=&quot;FoobarEXE&quot; Name=&quot;FoobarAppl10.exe&quot; DiskId=&quot;1&quot; Source=&quot;FoobarAppl10.exe&quot; KeyPath=&quot;yes&quot;&gt;
&lt;Shortcut Id=&quot;startmenuFoobar10&quot; Directory=&quot;ProgramMenuDir&quot; Name=&quot;Foobar 1.0&quot; WorkingDirectory=&quot;INSTALLDIR&quot; Icon=&quot;Foobar10.exe&quot; IconIndex=&quot;0&quot; Advertise=&quot;yes&quot; /&gt;
&lt;Shortcut Id=&quot;desktopFoobar10&quot; Directory=&quot;DesktopFolder&quot; Name=&quot;Foobar 1.0&quot; WorkingDirectory=&quot;INSTALLDIR&quot; Icon=&quot;Foobar10.exe&quot; IconIndex=&quot;0&quot; Advertise=&quot;yes&quot; /&gt;
&lt;/File&gt;
&lt;/Component&gt;
&lt;Component Id=&quot;HelperLibrary&quot; Guid=&quot;173FE012-0F1C-45A6-BC79-BBFB363B45F9&quot;&gt;
&lt;File Id=&quot;HelperDLL&quot; Name=&quot;Helper.dll&quot; DiskId=&quot;1&quot; Source=&quot;Helper.dll&quot; KeyPath=&quot;yes&quot; /&gt;
&lt;/Component&gt;
&lt;Component Id=&quot;Manual&quot; Guid=&quot;B92B5ED5-FB38-4632-8FF0-CD1B37D9E67D&quot;&gt;
&lt;File Id=&quot;Manual&quot; Name=&quot;Manual.pdf&quot; DiskId=&quot;1&quot; Source=&quot;Manual.pdf&quot; KeyPath=&quot;yes&quot;&gt;
&lt;Shortcut Id=&quot;startmenuManual&quot; Directory=&quot;ProgramMenuDir&quot; Name=&quot;Instruction Manual&quot; Advertise=&quot;yes&quot; /&gt;
&lt;/File&gt;
&lt;/Component&gt;
&lt;/Directory&gt;
&lt;/Directory&gt;
&lt;/StandardDirectory&gt;
&lt;StandardDirectory Id=&quot;ProgramMenuFolder&quot;&gt;
&lt;Directory Id=&quot;ProgramMenuDir&quot; Name=&quot;Foobar 1.0&quot;&gt;
&lt;Component Id=&quot;ProgramMenuDir&quot; Guid=&quot;6B7F1E7C-01F6-4936-A107-BD75D8C3814F&quot;&gt;
&lt;RemoveFolder Id=&quot;ProgramMenuDir&quot; On=&quot;uninstall&quot; /&gt;
&lt;RegistryValue Root=&quot;HKCU&quot; Key=&quot;Software\[Manufacturer]\[ProductName]&quot; Type=&quot;string&quot; Value=&quot;&quot; KeyPath=&quot;yes&quot; /&gt;
&lt;ServiceInstall
Id=&quot;FooServiceInstaller&quot;
Type=&quot;ownProcess&quot;
Name=&quot;fooservice&quot;
DisplayName=&quot;Foo Service&quot;
Description=&quot;Foo Service&quot;
Interactive=&quot;no&quot;
Start=&quot;auto&quot;
ErrorControl=&quot;ignore&quot; &gt;
&lt;util:ServiceConfig
FirstFailureActionType=&quot;restart&quot;
SecondFailureActionType=&quot;restart&quot;
ThirdFailureActionType=&quot;restart&quot;
RestartServiceDelayInSeconds=&quot;1&quot; /&gt;
&lt;/ServiceInstall&gt;
&lt;/Component&gt;
&lt;/Directory&gt;
&lt;/StandardDirectory&gt;
&lt;StandardDirectory Id=&quot;DesktopFolder&quot; /&gt;
&lt;/Package&gt;
&lt;/Wix&gt;
The project file wix_example.wixproj:
&lt;Project Sdk=&quot;WixToolset.Sdk/4.0.1&quot; ToolsVersion=&quot;4.0&quot;&gt;
&lt;ItemGroup&gt;
&lt;PackageReference Include=&quot;WixToolset.Netfx.wixext&quot; Version=&quot;4.0.1&quot; /&gt;
&lt;PackageReference Include=&quot;WixToolset.Util.wixext&quot; Version=&quot;4.0.1&quot; /&gt;
&lt;/ItemGroup&gt;
&lt;/Project&gt;
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
[1]: https://www.firegiant.com/system/files/samples/SampleFirst.zip
</details>
# 答案1
**得分**: 1
命名空间是`http://wixtoolset.org/schemas/v4/wxs/util`,不是`http://wixtoolset.org/schemas/v4/wxs/Util`。
文档位于https://wixtoolset.org/docs/schema/util/。
<details>
<summary>英文:</summary>
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/.
</details>

huangapple
  • 本文由 发表于 2023年7月31日 20:41:35
  • 转载请务必保留本文链接:https://go.coder-hub.com/76803738.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定