简体   繁体   English

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

[英]C# Wix Service installer - Unresolved reference to symbol

I crated a service in C# with Viwual Studio 2017. 我使用Viwual Studio 2017在C#中创建了一项服务。

Now I'm trying to create an installer with Wix. 现在,我正在尝试使用Wix创建安装程序。 It's not my first time with wix, but this time I can't build my setup. 这不是我第一次使用wix,但是这次我无法建立我的设置。 I have error : 我有错误:

Unresolved reference to symbol 'Component:InstallComponents' in section 'Product:*'. 在“产品:*”部分中未解析对符号“ Component:InstallComponents”的引用。

I saw some topic about this, but it did not solve my problem. 我看到了一些与此相关的主题,但是并不能解决我的问题。

There is my product.wxs : 这是我的product.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 exists in ComponentGroup , I don't understand why I have this error. InstallComponents存在于ComponentGroup ,我不明白为什么会有这个错误。

The mistake was in my Feature. 错误出在我的专题文章中。

My InstallComponents is define as ComponentGroup, so to install it, my feature must be like this : 我的InstallComponents定义为ComponentGroup,因此要安装它,我的功能必须像这样:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM