问题
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:
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)" />
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:
- Right click
"References"
in your WiX project =>Add Reference...
- Under
"Projects"
select the project you want to refer to, pressAdd
andOK
.
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