WiX"未定义的预处理器变量"尽管.wxi文件中有变量

时间:2015-12-03 21:44:20

标签: visual-studio wix

我在visual studio中有一个包含两个文件的WiX项目:Product.wxs和config.wxi。

当我尝试构建这个项目时,我收到以下错误:"未定义的预处理器变量' $(var.ProductName)'。"

我在这里做错了包含文件显然没有被识别?

config.wxi

<?xml version="1.0" encoding="utf-8"?>
<Include>
  <?Define Manufacturer = "My Company" ?>
  <?Define ProductName = "My Product" ?>
  <?Define Version = "1.0.0.0" ?>
  <?Define BuildType = "Development" ?>
  <?Define BuildTypeShort = "Dev" ?>
</Include>

Product.wxs:

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
  <?include config.wxi ?>
  <Product Id="*" Name="$(var.ProductName)" Language="1033" Version="$(var.Version)" Manufacturer="$(var.Manufacturer)" UpgradeCode="6e7efd44-0149-416b-871d-418ba6365e1b">
    <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
        <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
        <MediaTemplate />
        <Feature Id="ProductFeature" Title="MySetup" Level="1">
            <ComponentGroupRef Id="ProductComponents" />
        </Feature>
    </Product>
    <Fragment>
        <Directory Id="TARGETDIR" Name="SourceDir">
            <Directory Id="ProgramFilesFolder">
        <Directory Id="ManufacturerFolder" Name="$(var.Manufacturer)">
          <Directory Id="INSTALLFOLDER" Name="$(var.ProductName)" />
        </Directory>
            </Directory>
        </Directory>
    </Fragment>
    <Fragment>
        <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
            <Component Id="ProductComponent">
        <File Source="$(var.SomeProjectA.TargetPath)"/>
        <File Source="$(var.SomeProjectB.TargetPath)"/>
            </Component>
    </ComponentGroup>
    </Fragment>
</Wix>

1 个答案:

答案 0 :(得分:2)

使用“define”而不是“Define”。

在这里:

   <?xml version="1.0" encoding="utf-8"?>
   <Include>
      <?define Manufacturer = "My Company" ?>
      <?define ProductName = "My Product" ?>
      <?define Version = "1.0.0.0" ?>
      <?define BuildType = "Development" ?>
      <?define BuildTypeShort = "Dev" ?>
    </Include>