繁体   English   中英

WIX 使用 x64 安装 Windows 服务

[英]WIX install windows service with x64

我不得不将我的项目更改为 x64,现在按照教程,我也尝试将我的 WIX 安装更改为 x64。 但是 WIX 安装会尝试安装 Windows 服务。 此服务使用msiexec /i Setup.msi /L*V install.log在 install.log 中引发以下异常:

System.Reflection.TargetInvocationException:调用目标导致异常。 ---> System.BadImageFormatException: 未找到文件或程序集“服务,版本 = 1.0.0.0,文化 = 中性,PublicKeyToken = null”或其依赖项。 试图加载格式错误的文件。

在 SaveServiceConfigurationAction.CustomActions.SaveServiceConfiguration(Session session)
--- 内部异常批量监控结束---
bei System.RuntimeMethodHandle.InvokeMethod(Object target, Object arguments, Signature sig, Boolean constructor)
bei System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object parameters, Object arguments)
bei System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture)
在 Microsoft.Deployment.WindowsInstaller.CustomActionProxy.InvokeCustomAction(Int32 sessionHandle, String entryPoint, IntPtr remotingDelegatePtr)

CustomAction SaveServiceConfigurationAction 返回实际错误代码 1603(请注意,如果在沙箱内进行翻译,这可能不是 100% 准确)

当我尝试使用installutil.exe安装此服务时,出现类似异常

System.BadImageFormatException: 未找到文件或程序集“Service.exe”或其依赖项。 试图加载格式错误的文件。

但是,如果我使用Framework64\\v4.0.30319\\installutil.exe则可以Framework64\\v4.0.30319\\installutil.exe地安装该服务。

所以现在我的问题是:如何配置我的 WIX 项目以使用 Framework64 来安装服务?

我的 WIX 代码:

<Component Id="CMP_Service" Feature="Core">
            <File Source="$(var.Service.TargetPath)" KeyPath="yes">
              <fire:FirewallException Id="ServiceException" Name="Service Exception" Protocol="tcp" Port="[PORTProperty]" Scope="any" />
            </File>
            <ServiceInstall Id="ServiceInstallELS"
                            Name="Service"
                            Description="..."
                            Start="auto"
              Account="[SERVICEACCOUNT]"
                            ErrorControl="normal"
                            Type="ownProcess"
              Vital="no" />
            <ServiceControl Id="ServiceControllELS"
                            Name="Service"
                            Start="install"
                            Stop="both"
                            Remove="uninstall"
                            Wait="no" />
          </Component>

请检查这个。

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <?define DemoMarketingContacts.UI_TargetDir=$(var.DemoMarketingContacts.UI.TargetDir)?>
  <?define DemoMarketingContacts.UploaderUI_TargetDir=$(var.DemoMarketingContacts.UploaderUI.TargetDir)?>
  <?define DemoMarketingContacts.ValidatorUI_TargetDir=$(var.DemoMarketingContacts.ValidatorUI.TargetDir)?>
  <?define DemoMarketingContacts.Domain_TargetDir=$(var.DemoMarketingContacts.Domain.TargetDir)?>
  <?define QueryStringUtilies_TargetDir=$(var.QueryStringUtilies.TargetDir)?>
  <?define Demo.InternetCheckerService_TargetDir=$(var.Demo.InternetCheckerService.TargetDir)?>
  <?define Demo.InternetChecker.Server_TargetDir=$(var.Demo.InternetChecker.Server.TargetDir)?>
  
  <Product Id="50D6E335-B3EF-44EE-B3AE-899B260F8FBF" Name="Demo Marketing Contacts" Language="1033" Version="4.0.0.0" 
           Manufacturer="Demo Technologies (pvt)Ltd." UpgradeCode="495757a4-415c-4dbe-81fb-a6fa78c40a5b">
    <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />

    <Icon Id="EmailMarketing.ico" SourceFile="$(var.ProjectDir)Email Marketing.ico" />
    <Icon Id="UploadEmail.ico" SourceFile="$(var.ProjectDir)UploadEmail.ico" />
    <Icon Id="ValidEmail.ico" SourceFile="$(var.ProjectDir)ValidEmail.ico" />
    
    <Property Id="AppIcon" Value="Email Marketing" />
    <Property Id="ARPPRODUCTICON" Value="EmailMarketing.ico" />

    <!--<UIRef Id="WixUI_Minimal" />-->
    <UIRef Id="DemoSetUpUI" />

    <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed."  />
    
    <MediaTemplate EmbedCab="yes" />

    <Feature Id="ProductFeature" Title="DemoMarketing Contacts" Level="1" TypicalDefault="install">
      <ComponentGroupRef Id="ProductComponents" />
      <ComponentRef Id="ApplicationShortcut" />
      <ComponentRef Id="ApplicationShortcutDesktop" />
      <ComponentRef Id="AuditLogFolderComponent" />
      <ComponentRef Id="LogFolderComponent" />
    </Feature>    
    <Feature Id="ValidatorFeature" Title="DemoMarketing Contacts Validator" Level="1" TypicalDefault="install">
      <ComponentGroupRef Id="ValidatorUIComponents" />
      <ComponentRef Id="ApplicationShortcut" />
      <ComponentRef Id="ApplicationShortcutDesktop" />
    </Feature>
    
    <Feature Id="InternetCheckerServiceFeature" Title="Demo Internet Checker" Level="2" Description="This is the Demo Internet Checker Service component" TypicalDefault="advertise">
      <ComponentGroupRef Id="ServiceComponetGroup" />
    </Feature>

  </Product>

  <Fragment>
    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="ProgramFilesFolder">
        <Directory Id="INSTALLFOLDER" Name="Demo Marketing Contacts">
          <Directory Id="AuditLogFolder" Name="AuditLog" />
          <Directory Id="LogFolder" Name="Log" />
        </Directory>
      </Directory>
      <Directory Id="ProgramMenuFolder">
        <Directory Id="ApplicationProgramsFolder" Name="DemoMarketing Contacts" />
      </Directory>
      <Directory Id="DesktopFolder" Name="Desktop" />
    </Directory>
  </Fragment>

  <Fragment>
    <DirectoryRef Id="ApplicationProgramsFolder">
      <Component Id="ApplicationShortcut" Guid="A65731C2-FDFB-4C41-BD8B-8AD5E2E441B2">        
        <Shortcut Id="UploaderStartMenuShortcut" Name="DemoMarketing Contacts Uploader" Description="DemoMarketing Contacts Uploader" Target="[#DemoMarketingContacts.UploaderUI.exe]" WorkingDirectory="INSTALLFOLDER" />
        <Shortcut Id="ValidatorStartMenuShortcut" Name="DemoMarketing Contacts Validator" Description="DemoMarketing Contacts Validator" Target="[#DemoMarketingContacts.ValidatorUI.exe]" WorkingDirectory="INSTALLFOLDER" />
        <RemoveFolder Id="RemoveApplicationProgramsFolder" Directory="ApplicationProgramsFolder" On="uninstall" />
        <RegistryValue Root="HKCU" Key="Software\DemoMarketing Contacts" Name="installed" Type="integer" Value="1" KeyPath="yes" />
      </Component>
    </DirectoryRef>
    <DirectoryRef Id="DesktopFolder">
      <Component Id="ApplicationShortcutDesktop" Guid="6F764DEA-E1DE-418E-9B5C-4E09E6C5FB3E">
        
        <Shortcut Id="UploaderDesktopShortcut" Name="DemoMarketing Contacts Uploader" Description="DemoMarketing Contacts Uploader" Target="[#DemoMarketingContacts.UploaderUI.exe]" WorkingDirectory="INSTALLFOLDER" />
        <Shortcut Id="ValidatorDesktopShortcut" Name="DemoMarketing Contacts Validator" Description="DemoMarketing Contacts Validator" Target="[#DemoMarketingContacts.ValidatorUI.exe]" WorkingDirectory="INSTALLFOLDER" />
        <RemoveFolder Id="RemoveDesktopFolder" Directory="ApplicationProgramsFolder" On="uninstall" />
        <RegistryValue Root="HKCU" Key="Software\DemoMarketing Contacts" Name="installed" Type="integer" Value="1" KeyPath="yes" />
      </Component>
    </DirectoryRef>
    <DirectoryRef Id="AuditLogFolder">
      <Component Id="AuditLogFolderComponent" Guid="49FE9EB9-90A5-46D6-93FD-45FA153F53D5" KeyPath="yes">
        <CreateFolder />
      </Component>
    </DirectoryRef>
    <DirectoryRef Id="LogFolder">
      <Component Id="LogFolderComponent" Guid="B7CFA16B-B755-42F5-B9FE-AC161F758D53" KeyPath="yes">
        <CreateFolder />
      </Component>
    </DirectoryRef>
  </Fragment>

  <Fragment>
    <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">

      <Component Id="DemoMarketingContacts.UploaderUI.exe" Guid="25B57A38-AD92-430E-96C0-887F7826E69E">
        <File Id="DemoMarketingContacts.UploaderUI.exe" Name="DemoMarketingContacts.UploaderUI.exe" Source="$(var.DemoMarketingContacts.UploaderUI_TargetDir)DemoMarketingContacts.UploaderUI.exe" />
      </Component>

      <Component Id="DemoMarketingContacts.UploaderUI.exe.config" Guid="0DD136DB-D607-42F1-9FB6-24200E43AA80">
        <File Id="DemoMarketingContacts.UploaderUI.exe.config" Name="DemoMarketingContacts.UploaderUI.exe.config" Source="$(var.DemoMarketingContacts.UploaderUI_TargetDir)DemoMarketingContacts.UploaderUI.exe.config" />
      </Component>
      
      <Component Id="MySql.Data.dll" Guid="1cd1c916-b9cc-451d-be2f-c17bec362710">
        <File Id="MySql.Data.dll" Name="MySql.Data.dll" Source="$(var.DemoMarketingContacts.UI_TargetDir)MySql.Data.dll" />
      </Component>
      <Component Id="DbManagerLibrary.dll" Guid="8307fa02-f630-4f0b-9ca1-77784fcc716b">
        <File Id="DbManagerLibrary.dll" Name="DbManagerLibrary.dll" Source="$(var.DemoMarketingContacts.UI_TargetDir)DbManagerLibrary.dll" />
      </Component>

      <Component Id="Md5CryptoEngine.dll" Guid="0baf14db-3d30-4f20-913d-9bba02357d63">
        <File Id="Md5CryptoEngine.dll" Name="Md5CryptoEngine.dll" Source="$(var.DemoMarketingContacts.UI_TargetDir)Md5CryptoEngine.dll" />
      </Component>
      <Component Id="QueryStringUtilies.dll" Guid="fdf2e586-a590-4ca8-bd4b-ef0fcafcd8e5">
        <File Id="QueryStringUtilies.dll" Name="QueryStringUtilies.dll" Source="$(var.QueryStringUtilies_TargetDir)QueryStringUtilies.dll" />
      </Component>

      <Component Id="DemoMarketingContacts.Domain.dll" Guid="719641ed-d882-412f-a826-ebded804de08">
        <File Id="DemoMarketingContacts.Domain.dll" Name="DemoMarketingContacts.Domain.dll" Source="$(var.DemoMarketingContacts.Domain_TargetDir)DemoMarketingContacts.Domain.dll" />
      </Component>
      <Component Id="Conf.sys" Guid="8f8f0b68-8a2f-4e6e-81b8-296b6d1e3038">
        <File Id="Conf.sys" Name="Conf.sys" Source="$(var.DemoMarketingContacts.UI_TargetDir)Conf.sys" />
      </Component>
      <Component Id="LicenseKey.sys" Guid="b5478971-d1d6-4d6c-b254-ded5d8658ef7">
        <File Id="LicenseKey.sys" Name="LicenseKey.sys" Source="$(var.DemoMarketingContacts.UI_TargetDir)LicenseKey.sys" />
      </Component>
      <Component Id="System.Windows.Interactivity.dll" Guid="1d71080d-a57b-47b9-9cbf-64f430252846">
        <File Id="System.Windows.Interactivity.dll" Name="System.Windows.Interactivity.dll" Source="$(var.DemoMarketingContacts.UploaderUI_TargetDir)System.Windows.Interactivity.dll" />
      </Component>
      <Component Id="Caliburn.Micro.Platform.Core.dll" Guid="54fd8728-8a96-4d6e-bc14-2df25a47fbe5">
        <File Id="Caliburn.Micro.Platform.Core.dll" Name="Caliburn.Micro.Platform.Core.dll" Source="$(var.DemoMarketingContacts.UploaderUI_TargetDir)Caliburn.Micro.Platform.Core.dll" />
      </Component>
      <Component Id="Cobisi.EmailVerify.Net45.dll" Guid="feb50857-53b2-4c14-904e-2f86f25fa4d8">
        <File Id="Cobisi.EmailVerify.Net45.dll" Name="Cobisi.EmailVerify.Net45.dll" Source="$(var.DemoMarketingContacts.UploaderUI_TargetDir)Cobisi.EmailVerify.Net45.dll" />
      </Component>
      <Component Id="Caliburn.Micro.Platform.dll" Guid="c85997a8-0571-4a34-83cc-a12022f17ff7">
        <File Id="Caliburn.Micro.Platform.dll" Name="Caliburn.Micro.Platform.dll" Source="$(var.DemoMarketingContacts.UploaderUI_TargetDir)Caliburn.Micro.Platform.dll" />
      </Component>
      <Component Id="Caliburn.Micro.dll" Guid="50795ece-887e-43bf-811f-29806c37ea5b">
        <File Id="Caliburn.Micro.dll" Name="Caliburn.Micro.dll" Source="$(var.DemoMarketingContacts.UploaderUI_TargetDir)Caliburn.Micro.dll" />
      </Component>
      <Component Id="Demo.InternetCheckerService.exe.config" Guid="c60abb1b-7f57-4056-86a6-23aa7cf936db">
        <File Id="Demo.InternetCheckerService.exe.config" Name="Demo.InternetCheckerService.exe.config" Source="$(var.Demo.InternetCheckerService_TargetDir)Demo.InternetCheckerService.exe.config" />
      </Component>
      <Component Id="Email_Marketing.ico" Guid="bbb37327-15e9-44ab-9816-c0bfe09a7895">
        <File Id="Email_Marketing.ico" Name="Email Marketing.ico" Source="$(var.DemoMarketingContacts.UI_TargetDir)Email Marketing.ico" />
      </Component>
      <Component Id="Read_me.txt" Guid="31685dd1-c56f-4c70-89a9-f2327d143f17">
        <File Id="Read_me.txt" Name="Read me.txt" Source="$(var.DemoMarketingContacts.UI_TargetDir)Read me.txt" />
      </Component>
     

    </ComponentGroup>   
    
    <ComponentGroup Id="ValidatorUIComponents" Directory="INSTALLFOLDER">
       <Component Id="DemoMarketingContacts.ValidatorUI.exe" Guid="8672B6FC-6419-495D-A9C3-F3977F8B7B8F">
        <File Id="DemoMarketingContacts.ValidatorUI.exe" Name="DemoMarketingContacts.ValidatorUI.exe" Source="$(var.DemoMarketingContacts.ValidatorUI_TargetDir)DemoMarketingContacts.ValidatorUI.exe" />
      </Component>  
      
      <Component Id="DemoMarketingContacts.ValidatorUI.exe.config" Guid="28572FF1-B8D8-42DF-86C8-041FFBA9EA31">
        <File Id="DemoMarketingContacts.ValidatorUI.exe.config" Name="DemoMarketingContacts.ValidatorUI.exe.config" Source="$(var.DemoMarketingContacts.ValidatorUI_TargetDir)DemoMarketingContacts.ValidatorUI.exe.config" />
      </Component>
    </ComponentGroup>
    
    <ComponentGroup Id="ServiceComponetGroup" Directory="INSTALLFOLDER">
      <Component Id="ServiceComponent" Guid="28ABD97D-3091-485D-AF21-0BD96151D52B" DiskId="1" SharedDllRefCount="no" KeyPath="no" NeverOverwrite="no" Permanent="no" Transitive="no" Win64="no" Location="either">
        <File Id="Demo.InternetChecker.Server.dll" Name="Demo.InternetChecker.Server.dll" Source="$(var.Demo.InternetChecker.Server_TargetDir)Demo.InternetChecker.Server.dll" KeyPath="no" />
        <File Id="Demo.InternetCheckerService.exe" Name="Demo.InternetCheckerService.exe" Source="$(var.Demo.InternetCheckerService_TargetDir)Demo.InternetCheckerService.exe" ReadOnly="no" Compressed="yes" KeyPath="yes" Vital="yes" Hidden="no" System="no" Checksum="no" />
        <ServiceInstall Id="DemoInternetCheckerServiceInstall" DisplayName="Demo Internet Checker Service Instance" Description="This Service is broadcast internet availability to the intranet." Name="DemoInternetCheckerExeName" ErrorControl="normal" Start="auto" Type="ownProcess" Vital="yes" />
        <ServiceControl Id="DemoInternetCheckerServiceControl" Name="DemoInternetCheckerExeName" Start="install" Stop="uninstall" Remove="uninstall" />

      </Component>
    </ComponentGroup>
  </Fragment>
</Wix>

暂无
暂无

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

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