未定义的预处理器变量 '$(var.WixInstall.TargetPath)'.WixInstaller D:work\Extractor\WixInstaller\Product.wxs [英] Undefined preprocessor variable '$(var.WixInstall.TargetPath)'. WixInstaller D:work\Extractor\WixInstaller\Product.wxs

查看:18
本文介绍了未定义的预处理器变量 '$(var.WixInstall.TargetPath)'.WixInstaller D:work\Extractor\WixInstaller\Product.wxs的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用 wix 创建 Windows 安装程序时遇到以下错误.未定义的预处理器变量 '$(var.WixInstall.TargetPath)'.WixInstaller D:\work\Extractor\WixInstaller\Product.wxs

I'm facing the following error while create windows installer using wix. Undefined preprocessor variable '$(var.WixInstall.TargetPath)'. WixInstaller D:\work\Extractor\WixInstaller\Product.wxs

请注意:我尝试了以下答案但没有收获[Wix '未定义的预处理器变量' ,[WiX 未定义的预处理器变量 ,[WiX - 未定义的预处理器变量 '$(var.SetupProject1.TargetDir)'

Please Note: I have tried the following answers but no gain [Wix 'undefined preprocessor variable' , [WiX undefined preprocessor variable , [WiX - Undefined preprocessor variable '$(var.SetupProject1.TargetDir)'

Product.wxs 代码

Product.wxs code

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Product Id="*" Name="WixInstaller" Language="1033" Version="1.0.0.0" Manufacturer="" UpgradeCode="PUT-GUID-HERE">
        <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />

        <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
        <MediaTemplate />

        <Feature Id="ProductFeature" Title="WixInstaller" Level="1">
            <ComponentGroupRef Id="ProductComponents" />
        </Feature>
    </Product>

    <Fragment>
        <Directory Id="TARGETDIR" Name="SourceDir">
            <Directory Id="ProgramFilesFolder">
                <Directory Id="INSTALLFOLDER" Name="WixInstaller" />
            </Directory>
        </Directory>
    </Fragment>

    <Fragment>
        <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
             <Component Id="ProductComponent">
        <File Source="$(var.WixInstall.TargetPath)" />
      </Component>
        </ComponentGroup>
    </Fragment>
</Wix>

推荐答案

获得心跳:首先要做的是:编译源代码,以便检查是否存在是否还有其他问题:

Getting a Heartbeat: First things first: get your source to compile so you can check if there are other problems:

  1. 绝对路径:请尝试硬编码一个您知道目标位置存在的文件的完整路径:

  1. Absolute Path: Please try to hard code a full path to a file that you know exists at the target location:

 <File Source="D:\My Files\MyBinary.exe" />

  • 制造商:接下来设置制造商"将归于某事.只要有东西,任何东西都会做.输入您的公司名称 - 很明显.

  • Manufacturer: Next set the "Manufacturer" attribute to something. Anything will do so long as there is something there. Put your company name - obviously.

    =>尝试编译.这应该会成功.

    => Try to compile. This should succeed.

    缺少定义:好的,让我们试着解决这个问题.你从哪里得到这个预处理器结构:

    Missing Definition: OK, with a heartbeat going, let's try to solve the problem. Where are you getting this pre-processor construct from:

    <File Source="$(var.WixInstall.TargetPath)" />
    

    这是来自某个样本还是什么?我假设 "WixInstall" 是指 Visual Studio 解决方案中的 WiX 项目本身?通常,您可以像这样引用解决方案中的项目 - 按名称 - 但通常您会引用另一个项目,例如MyBinaryProject".你可以像这样引用它的构建输出:

    Is this from some sample or something? I assume "WixInstall" is referring to the WiX project itself inside the Visual Studio solution? Generally you can refer to projects inside your solution like this - by name - but normally you refer to another project, such as "MyBinaryProject" and you refer to its build output like this:

    <File Source="$(var.MyBinaryProject.TargetPath)" />
    

    您需要确保您引用的项目实际上在 Visual Studio 解决方案中.并且您需要添加对它的引用:

    You need to make sure the project you refer to is actually in the Visual Studio solution. And you need to add a reference to it:

    1. 在您的 WiX 项目中右键单击 References" =>添加引用...
    2. "Projects" 下选择您要引用的项目,按 Add>好的.


    WiX 文档:使用项目引用和变量 - 有关在引用其他 Visual Studio 项目时可用的内置变量的详细信息,请参阅 WiX 文档条目.


    WiX Documentation: Using Project References and Variables - please see that WiX documentation entry for details on the built-in variables available when you have referenced other Visual Studio projects.

    常规预处理器变量:除了添加对另一个 Visual Studio 项目的引用时获得的内置预处理器变量之外,您还可以定义自己的变量:

    Regular Preprocessor Variable: Besides the built-in preprocessor variable you get when you add a reference to another Visual Studio project, you can also define your own variables:

    <?define MyTest= "D:\My Files\MyBinary.exe" ?>
    <...>
    <File Source="$(var.MyTest)" />
    


    链接:

    这篇关于未定义的预处理器变量 '$(var.WixInstall.TargetPath)'.WixInstaller D:work\Extractor\WixInstaller\Product.wxs的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆