英文:
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'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][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:
<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
[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>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论