WiX安装功能驱动(Function Driver)

WiX提供了安装驱动的拓展,需要添加引用WixDifxAppExtension,而后添加schema:

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
     xmlns:difx='http://schemas.microsoft.com/wix/DifxAppExtension'>

INSTALLFOLDERDirectory元素节点下插入:

                    <Directory Id='DirFilterAppDrivers' Name='Drivers'>
                        <Directory Id='DirFilterDir' Name='DirFilter'>
                            <Component Id='DirFilterDriver' Guid='XXXX7571-XXXX-XXXX-9A52-9E216B203579'>
                                <File Id='DirFilterSYS' Name='*.sys' DiskId='1' Source='$(var.SourceFilesDir)\*.sys' KeyPath='yes' />
                                <File Id='DirFilterINF' Name='*.inf' DiskId='1' Source='$(var.SourceFilesDir)\*.inf' />
                                <File Id='DirFilterCAT' Name='*.cat' DiskId='1' Source='$(var.SourceFilesDir)\*.cat' />
                                <File Id='DirFilterDLL' Name='WdfCoinstaller01011.dll' DiskId='1' Source='$(var.SourceFilesDir)\WdfCoinstaller01011.dll' />
                                <difx:Driver Legacy='yes' />
                            Component>
                        Directory>
                    Directory>

这时候Rebuild依然有错误提示,我们需要手动修改项目文件,增加:

<WixLibrary Include="difxapp_x86.wixlib" />

或者

<WixLibrary Include="difxapp_x64.wixlib" />

具体如下:找到*.wixproj文件,新增元素:

   <ItemGroup>
    <WixLibrary Include="difxapp_x64">
      <HintPath>C:\Program Files (x86)\WiX Toolset v3.11\bin\difxapp_x64.wixlibHintPath>
      <Name>difxapp_x64Name>
    WixLibrary>
  ItemGroup>

至于是64还是32需要根据自己的驱动作区分。
参考:
1. How to reference WixDifxAppExtension in a .wixproj file?
2. LGHT0094 when using DifxAppExtension #1812
3. Use different libraries according to build platform
4. KK’s Blog

你可能感兴趣的:(WiX)