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

时间:2018-08-07 08:48:52

标签: c# wix

我使用Viwual Studio 2017在C#中创建了一项服务。

现在,我正在尝试使用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 个答案:

答案 0 :(得分:0)

错误在于我的功能。

我的evenodd = [] while True: try: n = int(input()) evenodd.append(n) except: break evenflag = 0 oddflag = 0 print(evenodd) for number in evenodd: if number % 2 == 0: evenflag += 1 oddflag = 0 else: oddflag += 1 evenflag = 0 if evenflag == 3: print("Found 3 consecutive even numbers") break elif oddflag == 3: print ("Found three consecutive odd numbers") break 被定义为ComponentGroup,因此要安装它,我的功能必须是这样的:

InstallComponents