Undefined preprocessor variable '$(var.WixInstall.TargetPath)'. WixInstaller D:work\Extractor\WixInstaller\Product.wxs

和自甴很熟 提交于 2021-01-28 12:27:30

问题


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

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

回答1:


Getting a Heartbeat: first things first, in order to get this to compile so we can verify that there are not other problems:

  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" />
    
  2. 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)" />

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)" />

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. Right click "References" in your WiX project => Add Reference...
  2. Under "Projects" select the project you want to refer to, press Add and OK.

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.


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)" />

Links:

  • More on advanced pre-processor features and other things: Wix Installer : Setting component condition property when doing a MSIEXEC admin install at command line
  • On different variable types in WiX: WiX (Windows Installer Xml), Create universal variables



回答2:


That code references a project called WiXInstall in your solution.

I recommend looking at: https://github.com/iswix-llc/iswix-tutorials



来源:https://stackoverflow.com/questions/56063159/undefined-preprocessor-variable-var-wixinstall-targetpath-wixinstallerdw

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!