I'm following this tutorial to create a WiX installer for a VS2017 Winform app
. It's just a default Winform app (nothing fancy). But when I build the WiX project (SetupProject1
shown in figure 1 below), I get the following error at first <File id=.../>
tag of ProductComponent.wxs
(shown below).
Question: What I may be missing here?
Note: I'm using this Wix Toolset Visual Studio 2017 Extension
Error:
Undefined preprocessor variable '$(var.SetupProject1.TargetDir)'
VS2017 Solution Explorer:
Product.wxs
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="89ae9543-fdf1-444b-9678-811483fd58bd" Name="SetupProject1" Language="1033" Version="1.0.0.0" Manufacturer="WiX_test_4_Winfrm" UpgradeCode="e69fe67b-5c28-4764-8196-a6613b840eff">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<UIRef Id="WixUI_Mondo" />
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLFOLDER"></Property>
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate EmbedCab="yes" />
<Feature Id="ProductFeature" Title="SetupProject1" Level="1">
<ComponentGroupRef Id="ProductComponents" />
</Feature>
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="SetupProject1" />
</Directory>
</Directory>
</Fragment>
<Fragment>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
<!-- TODO: Remove the comments around this Component element and the ComponentRef below in order to add resources to this installer. -->
<Component Id="CMP_SetupProject1">
<File Source="$(var.WIX_WinfrmTest.TargetPath)" />
</Component>
</ComponentGroup>
</Fragment>
</Wix>
ProductComponent.wxs
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<DirectoryRef Id="INSTALLFOLDER" />
</Fragment>
<Fragment>
<ComponentGroup Id="ProductComponents">
<Component Id="cmp2C5CB3BF0E009CA9CF5E03CADA38250D" Directory="INSTALLFOLDER" Guid="{C694E446-7B01-42C0-9056-4E09834809E9}">
<File Id="fil3A244EF6571347120C494BB170DC368E" KeyPath="yes" Source="$(var.SetupProject1.TargetDir)\cab1.cab" />
</Component>
<Component Id="cmpB6E89A2030E867C94B57A39FE26E1181" Directory="INSTALLFOLDER" Guid="{E8E1247F-627F-420D-97E0-0ABE39A2064C}">
<File Id="fil41A028F0E06C7EEE038806BDA5979087" KeyPath="yes" Source="$(var.SetupProject1.TargetDir)\SetupProject1.msi" />
</Component>
<Component Id="cmpD2FFED031AA728C90BED6090228F3AE3" Directory="INSTALLFOLDER" Guid="{660414BB-E061-4EE2-A7E2-471EA41C031F}">
<File Id="fil3F7C931DA08579E26A8F50778E59444A" KeyPath="yes" Source="$(var.SetupProject1.TargetDir)\SetupProject1.wixpdb" />
</Component>
</ComponentGroup>
</Fragment>
</Wix>
Just remove your second file ProductComponent.wxs should be OK.
The external tool mentioned on that blog is a good idea, but that should only be run by activating your winform project not your current project (the wix project).