visual-studio - WiX "Undefined Preprocessor Variable"尽管 .wxi 文件中有变量

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

产品.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>

最佳答案

使用“定义”而不是“定义”。

如下:

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

关于visual-studio - WiX "Undefined Preprocessor Variable"尽管 .wxi 文件中有变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34076769/

相关文章:

wix - 如何使用wix在安装过程中添加xml文件

asp.net - 在 WiX 安装程序中的应用程序池上设置禁用重叠回收

powershell - Wix - 安装然后运行 ​​powershell 脚本

c# - 加载到 powershell 进程时调试 C# dll?有可能吗?

c# - 多目标 .NET Framework 4 和 Visual Studio 2012

asp.net - 注销后 CSS 渲染问题

visual-studio - DocFX 为不同文件夹中的项目生成文档

visual-studio - 如何让 Resharper 正确包装很长的行?

c# - 使用 HeatDirectory 从 wix 中的多个目录中收集文件

c# - 错误 : a certificate chain processed, 但在根错误 .Net Framework 4.7 中终止