WiX - 未定义的预处理器变量'$(var.SetupProject1.TargetDir)'

问题描述 投票:0回答:1

我正在关注this tutorialVS2017 Winform app创建一个WiX安装程序。它只是一个默认的Winform应用程序(没什么特别的)。但是当我构建WiX项目(SetupProject1如下图1所示)时,我首先在<File id=.../>ProductComponent.wxs标签上得到以下错误(如下所示)。

问题:我在这里可能缺少什么?

注意:我正在使用这个Wix Toolset Visual Studio 2017 Extension

错误:

未定义的预处理器变量'$(var.SetupProject1.TargetDir)'

VS2017 Solution Explorer:

enter image description here

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>
c# winforms wix
1个回答
1
投票

只需删除你的第二个文件ProductComponent.wxs应该没问题。

该博客上提到的外部工具是一个好主意,但这应该只通过激活您的winform项目而不是当前项目(wix项目)来运行。

© www.soinside.com 2019 - 2024. All rights reserved.