代码之家  ›  专栏  ›  技术社区  ›  Armen Michaeli

使用Wix将整个目录添加到MSI数据库的规范方法是什么?

wix
  •  0
  • Armen Michaeli  · 技术社区  · 6 年前

    目录位于非本地(用于生成脚本等)位置,例如 C:\path\to\baz .

    %ProgramFiles%\foobar\baz ,它依赖于我正在开发的软件。

    Wix的 heat 程序似乎是为这个工作而设计的——获取目录的内容( baz

    heat.exe dir C:/path/to/baz -gg -dr baz -srd -cg baz baz.heat.wxs
    

    问题是 前置 SourceDir\ 逐字指向它所定位的每个文件的路径:

    <?xml version="1.0" encoding="utf-8"?>
    <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
        <Fragment>
            <DirectoryRef Id="baz" />
        </Fragment>
        <Fragment>
            <ComponentGroup Id="electron">
                <Component Id="cmp9C432873A67498F6C219E9E15596F0D8" Directory="baz" Guid="33D27AF6-A2E4-459C-818B-876268705883">
                    <File Id="filE773982796F85DF928701AF071140DE5" KeyPath="yes" Source="SourceDir\api-ms-win-core-console-l1-1-0.dll" />
                </Component>
                <!-- Other Component and nested File elements omitted. -->
            </ComponentGroup>
        </Fragment>
    <Wix>
    

    我不知道它为什么会这样做,我知道也有一些事情,如绑定变量和其他类型的变量,但无论如何,Wix链接器不会组装MSI,因为它无法源生成的源XML文件中指定的文件:

    baz.heat.wxs(12) : error LGHT0103 : The system cannot find the file 'SourceDir\api-ms-win-core-console-l1-1-0.dll'
    

    我正在链接由 像上面一样,我称之为“主”源文件,它实际上定义了安装的特性以及 巴兹 将安装目录:

    <?xml version="1.0" encoding="utf-8" ?>
    <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
        <Product Name="Foobar" Manufacturer="Acme" Id="2c05b2af-3adf-4901-b126-5a839c67978d" UpgradeCode="6db7d46b-5152-4e67-9615-c3f3c4dc205c" Language="1033" Codepage="1252" Version="7.0.0">
            <Package Id="*" Description="Acme Foobar Installer" Languages="1033" SummaryCodepage="1252" Compressed="yes" InstallerVersion="200" Keywords="Installer" Manufacturer="Acme" />
            <MediaTemplate EmbedCab="yes" />
            <Directory Id="TARGETDIR" Name="SourceDir">
                <Directory Id="ProgramFilesFolder">
                    <Directory Id="INSTALLDIR" Name="Foobar">
                        <Directory Id="baz" Name="baz" />
                    </Directory>
                </Directory>
            </Directory>
            <Feature Id="lanthir" Level="1">
                <ComponentGroupRef Id="baz" />
            </Feature>
    </Product>
    

    • SourceDir 除了逐字目录引用,还有别的什么吗?
    • 什么是经典的方法 生成正确的路径,可以按原样链接而不出现问题,或者使用链接器工具( light )解析生成的路径 默认情况下?

    我有一种感觉,我正在解决一个极其简单和常见的问题,应该有一个非常知名和明显的解决方案。我更愿意为链接器提供一个变量,这样当需要嵌入的目录的实际路径发生更改时,就不必重新生成源文件。

    1 回复  |  直到 6 年前
        1
  •  0
  •   daughey    6 年前

    您需要使用-var命令行打开heat。这将用$(var.whateveryouputtefthevararg)代替SourceDir。

    heat.exe dir C:/path/to/baz -gg -dr baz -srd -cg baz -var var.BazDir baz.heat.wxs 
    

    会导致更像

    <File Id="filE773982796F85DF928701AF071140DE5" KeyPath="yes" Source="$(var.BazDir)\api-ms-win-core-console-l1-1-0.dll" />
    

      <PropertyGroup>
         <ProjectDefineConstants>BazDir=PathToBazDirectory;$(ProjectDefineConstants)</ProjectDefineConstants>
      </PropertyGroup>