我在 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/