代码之家  ›  专栏  ›  技术社区  ›  A.Pissicat

C#Wix服务安装程序-对符号的未解析引用

  •  0
  • A.Pissicat  · 技术社区  · 7 年前

    我在C#与Viwual工作室于2017年提供了一项服务。

    现在我试图用Wix创建一个安装程序。这不是我第一次使用wix,但这次我不能建立我的设置。我有错误:

    中对符号“Component:InstallComponents”的未解析引用 “产品:*”部分。

    我看到了一些关于这个的话题,但它没有解决我的问题。

    有我的产品。wxs:

    <?xml version="1.0" encoding="UTF-8"?>
    <?define compagny = "myCompagny"?>
    <?define product = "Service Name"?>
    <?define service = "MyService"?>
    <?define version = "!(bind.FileVersion.MyService.exe)"?>
    <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
        <Product Id="*" 
               Name="$(var.product)"
               Language="1033"
               Version="$(var.version)"
               Manufacturer="$(var.compagny)" 
               UpgradeCode="XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX">
            <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" InstallPrivileges="elevated"/>
            <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
            <Media Id="1" Cabinet="MyService.cab" EmbedCab="yes" />
    
            <Directory Id="TARGETDIR" Name="SourceDir">
                <Directory Id="ProgramFilesFolder">
            <Directory Id="CGYFOLDER" Name="$(var.compagny)">
              <Directory Id="INSTALLFOLDER" Name="$(var.product)" />
            </Directory>
                </Directory>
            </Directory>
    
        <ComponentGroup Id="InstallComponents">
          <Component Id="InstallService" Guid="XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX" Directory="INSTALLFOLDER">
            <File Id="MyService.exe.config"
                  Name="$(var.service).exe.config"
                  Source="$(var.MyService.TargetDir)\$(var.service).exe.config"
                  Vital="yes"/>
            <RemoveFile Id="ALLFILES" Name="*.*" On="both" />
            <ServiceInstall Id="ServiceInstaller"
                            Type="ownProcess"
                            Vital="yes"
                            Name="$(var.service)"
                            DisplayName="$(var.product)"
                            Description=""
                            Start="auto"
                            Account="LocalSystem"
                            ErrorControl="normal" />
            <ServiceControl Id="Service_Start" Name="MyService" Start="install" Wait="no" />
            <ServiceControl Id="Service_Stop" Name="MyService"  Stop="both" Remove="uninstall" Wait="yes" />
          </Component>
        </ComponentGroup>
    
        <!-- Tell WiX to install the files -->
        <Feature Id="ProductFeature" Title="$(var.product)" Level="1">
          <ComponentRef Id="InstallComponents" />
        </Feature>
        </Product>
    </Wix>
    

    InstallComponents 存在于 ComponentGroup ,我不明白我为什么会犯这个错误。

    1 回复  |  直到 7 年前
        1
  •  0
  •   A.Pissicat    7 年前

    这个错误出现在我的特写里。

    我的 InstallComponents 定义为组件组,因此要安装它,我的功能必须如下:

    <Feature Id="ProductFeature" Title="$(var.product)" Level="1">
      <ComponentGroupRef Id="InstallComponents" />
    </Feature>
    
    推荐文章