2012-02-02 3 views
2

동일한 실행 파일을 사용하여 여러 Windows 서비스를 설치하려고하지만 WiX는 두 파일 태그의 동일한 이름 속성을 좋아하지 않습니다. 두 파일 태그의 이름을 변경하려고했습니다. 그것은 작동하지만 두 개의 동일한 실행 파일을 설치하지 않아도된다고 생각합니다. 이 작업을 수행하는 더 좋은 방법이 있습니까?Wix - 하나의 실행 파일로 여러 Windows 서비스를 설치하는 방법?

<Component Id="Service1" Guid="{SOMEGUID1}"> 
    <File Id='Service1' Name='ConnDriver.exe' DiskId='1' Source='..\Service\obj\x86\$(var.BUILD)\ConnDriver.exe' KeyPath='yes'/> 
    <ServiceInstall 
     Id="ServiceInstaller1" 
     Type="ownProcess" 
     Name="MyService1" 
     DisplayName="MyService1" 
     Description="Some Description" 
     Start="auto" 
     Account="[SERVICEACCOUNT]" 
     Password="[SERVICEPASSWORD]" 
     ErrorControl="normal" 
     Arguments=' "Service1"' 
     Vital="yes" 
     Interactive="no" /> 
    <ServiceControl Id="ServiceControl1" Stop="uninstall" Remove="uninstall" Name="MyService1" Wait="yes" /> 
</Component> 

<Component Id="Service2" Guid="{SOMEGUID2}"> 
    <File Id='Service2' Name='ConnDriver.exe' DiskId='1' Source='..\Service\obj\x86\$(var.BUILD)\ConnDriver.exe' KeyPath='yes'/> 
    <ServiceInstall 
     Id="ServiceInstaller2" 
     Type="ownProcess" 
     Name="MyService2" 
     DisplayName="MyService2" 
     Description="Some Description" 
     Start="auto" 
     Account="[SERVICEACCOUNT]" 
     Password="[SERVICEPASSWORD]" 
     ErrorControl="normal" 
     Arguments=' "Service2"' 
     Vital="yes" 
     Interactive="no" /> 
    <ServiceControl Id="ServiceControl2" Stop="uninstall" Remove="uninstall" Name="MyService2" Wait="yes" /> 
</Component> 

기능에서 : 어떤 도움에 감사드립니다

<Feature Id="Feature1" Title="Feature 2" Level="1" Description="..."> 
    <ComponentRef Id="Service1_xml"/> 
    <ComponentRef Id="Service1"/> 
</Feature> 
<Feature Id="Feature2" Title="Feature 2" Level="1" Description="..."> 
    <ComponentRef Id="Service2_xml"/> 
    <ComponentRef Id="Service2"/> 
</Feature> 

여기에 지금까지 내 코드입니다.

(추신 : 내가 2 개 구성 요소로 구성한 이유는 기능 섹션에 xml 구성 파일을 포함시킬 수 있기 때문입니다. 내 Windows 서비스 설치 관리자는 명령 줄 인수를 사용하여 읽고) 따라 구성

편집 :

오류 출력 : ICE30

: 대상 파일 'hlo8twix.exe | ConnDriver.exe가' '[ProgramFilesFolder] \ 회사 명 \ programName을 \'에 설치 LFN 시스템의 두 가지 구성 요소 인 'Service1'과 'Service2'로 구성됩니다. 이렇게하면 구성 요소 참조 카운팅이 중단됩니다.

+0

당신은 윅스 출력을 포함 할 수 있을까요? –

+0

이 모양은 Windows의 특성상 사용자 지정 작업을 통해서만 수행 할 수 있습니다. http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/Using-the-same-exe-file -for-different-services-in-one-MSI-td6520212.html – Jazon

+0

사용자 지정 작업을 사용하여 가능하다는 것을 확인할 수 있습니다. –

답변

2

내 프로젝트 중 하나에서 실행 파일 하나 안에 2 개의 서비스가 있습니다. 그래서 내 exe에서 두 서비스에 대해, 나는 내 윅스 설정에서 다음과 같습니다. 희망이 도움이됩니다.

<Component Id="MyScheduler" Guid="{SOMEGUID}"> 
    <File Id="MySchedulerEXE" Name="MyScheduler.exe" Source="MyScheduler.exe" KeyPath="yes" /> 

    <ServiceInstall Id="FirstService" Type="ownProcess" Vital="yes" Name="First Service" DisplayName="First Service" Description="First Service" Start="auto" Account="NT AUTHORITY\LocalService" Interactive="no" ErrorControl="ignore" /> 
    <ServiceControl Id="StartFirstService" Name="First Service" Start="install" Wait="no" /> 
    <ServiceControl Id="StopFirstService" Name="First Service" Stop="both" Wait="yes" Remove="uninstall" /> 

    <ServiceInstall Id="SecondService" Type="ownProcess" Vital="yes" Name="Second Service" DisplayName="Second Service" Description="Second Service" Start="auto" Account="NT AUTHORITY\LocalService" Interactive="no" ErrorControl="ignore" /> 
    <ServiceControl Id="StartSecondService" Name="Second Service" Start="install" Wait="no" /> 
    <ServiceControl Id="StopSecondService" Name="Second Service" Stop="both" Wait="yes" Remove="uninstall" /> 

    </Component> 
+0

고마워, 그게 내가 한 것과 똑같은거야. 내 경우에는 트위스트가 있었지만 설치하려는 서비스 인스턴스의 수를 선택할 수있었습니다. 이렇게하려면 전체 구성 요소를 배타적 조건으로 복제해야했습니다. 하나의 구성 요소는 하나의 설치/제어 쌍, 다른 하나는 두 쌍, 다른 하나는 세 개 등이 있습니다. –

+1

나는 이것을 시도했지만 제대로 작동하지 않습니다. 'ServiceBase.Run()'에 전달 된'ServiceBase'의 배열에서 첫 번째 서비스가 실행되지만, 그 뒤에 오는 서비스는 실행되지 않습니다. 어떤 아이디어? – Farinha

+0

나는 Farinha와 같은 문제가있다. "InstallUtil.exe"로 설치하면 두 서비스가 정상적으로 실행됩니다. 그러나 wix installer를 사용하면 첫 번째 실행 만합니다. 사실 그것은 이름에 신경 쓰지 않고 첫 번째 서비스 만 실행합니다.누군가가 문제를 찾아주십시오 – Gurpreet

0

구성 요소는 둘 이상의 기능에 속할 수 있습니다. 서비스에 대한 단일 구성 요소를 작성한 후 여러 기능을 작성하십시오. 각 기능에는 하나의 서비스 컴포 M 트에 대한 ComponentRef W 필요한 다른 참조가 있습니다.

+0

제안 해 주셔서 감사합니다.하지만 어려운 부분은 각 기능으로 변경하려는 명령 줄 인수를 얻는 방법을 찾는 것입니다. – Jazon

0

마지막으로 해결책을 찾았습니다. 동일한 exe에있는 다중 서비스의 경우 ServiceInstall 요소에 Type = "shareProcess"를 설정해야하며 두 서비스 모두 정상적으로 작동합니다. "InstallUtil"을 사용하여 서비스를 설치하고 레지스트리 구조를 비교하여이 사실을 발견했습니다. "InstallUtil"type을 ownProcess로 설정 했으므로 설치 프로그램에서 내 것을 변경 했으므로 매력적이었습니다. 우리가 어떻게 실패 년대의 더 나은 아이디어를 가질 수 있도록

<Component Id="MyScheduler" Guid="{SOMEGUID}"> 
<File Id="MySchedulerEXE" Name="MyScheduler.exe" Source="MyScheduler.exe" KeyPath="yes" /> 

    <ServiceInstall Id="FirstService" Type="shareProcess" Vital="yes" Name="First Service" DisplayName="First Service" Description="First Service" Start="auto" Account="NT AUTHORITY\LocalService" Interactive="no" ErrorControl="ignore" /> 
    <ServiceControl Id="StartFirstService" Name="First Service" Start="install" Wait="no" /> 
    <ServiceControl Id="StopFirstService" Name="First Service" Stop="both" Wait="yes" Remove="uninstall" /> 

    <ServiceInstall Id="SecondService" Type="shareProcess" Vital="yes" Name="Second Service" DisplayName="Second Service" Description="Second Service" Start="auto" Account="NT AUTHORITY\LocalService" Interactive="no" ErrorControl="ignore" /> 
    <ServiceControl Id="StartSecondService" Name="Second Service" Start="install" Wait="no" /> 
    <ServiceControl Id="StopSecondService" Name="Second Service" Stop="both" Wait="yes" Remove="uninstall" /> 

    </Component> 
0
<?xml version="1.0" encoding="UTF-8"?> 
<!-- The name of the product --> 
<?define Service1Name = "Test Service1" ?> 
<?define Service2Name = "Test Service2" ?> 
<!-- The description of the product --> 
<?define Service1Description = "Test Service1 that logs dummy text on an interval to a text file." ?> 
<?define Service2Description = "Test Service2 that logs dummy text on an interval to a text file." ?> 
<!-- The manufacturer, for setup package publisher and folder info --> 
<?define Manufacturer = "Your Company" ?> 
<!-- The version number of this setup package--> 
<?define Version = "1.0.1" ?> 
<!-- UpgradeCode must be unique and not changed once the first version of the program is installed. --> 
<?define UpgradeCode = "{1240E0CD-B3D2-44A7-B064-11B3C0709D69}" ?> 

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"> 
    <Product Id="*" Name="$(var.Service1Name)" Manufacturer="$(var.Manufacturer)" UpgradeCode="$(var.UpgradeCode)" Version="$(var.Version)" Language="1033"> 
    <!-- Create a folder inside Your Company called Test Service --> 
    <Package InstallerVersion="300" Compressed="yes"/> 
    <!-- Create a folder inside Your Company called Test Service --> 
    <Media Id="1" Cabinet="TestService.cab" EmbedCab="yes" /> 
    <!-- Allow upgrades and prevent downgrades --> 
    <MajorUpgrade DowngradeErrorMessage="A later version of [ProductName] is already installed. Setup will now exit." /> 
    <!-- Define the directory structure --> 
    <Directory Id="TARGETDIR" Name="SourceDir"> 
     <Directory Id="ProgramFilesFolder"> 
     <!-- Create a folder inside program files called Your Company --> 
     <Directory Id="ROOTDIRECTORY" Name="$(var.Manufacturer)"> 
      <!-- Create a folder inside Your Company called Test Service --> 
      <Directory Id="INSTALLFOLDER" Name="$(var.Service1Name)" /> 
     </Directory> 
     </Directory> 
    </Directory> 
    <!-- The files inside this DirectoryRef are linked to the Test Service directory via INSTALLFOLDER --> 
    <DirectoryRef Id="INSTALLFOLDER"> 
     <!-- Create a single component which is the TestService.exe file --> 
     <Component Id="$(var.TestService1.TargetFileName)"> 
     <!-- Copies the TestService.exe file using the project reference preprocessor variables --> 
     <File Id="$(var.TestService1.TargetFileName)" Source="$(var.TestService1.TargetPath)" KeyPath="yes" /> 
     <!-- Remove all files from the INSTALLFOLDER on uninstall --> 
     <RemoveFile Id="RemoveService1" Name="*.*" On="both" /> 
     <!-- Tell WiX to install the Service --> 
     <ServiceInstall Id="Service1Installer" 
     Type="ownProcess" 
     Name="TestService1" 
     DisplayName="$(var.Service1Name)" 
     Description="$(var.Service1Description)" 
     Start="auto" 
     ErrorControl="normal" /> 
     <!-- Tell WiX to start the Service --> 
     <ServiceControl Id="StartService1" Start="install" Stop="both" Remove="uninstall" Name="TestService1" Wait="yes" /> 
     </Component> 
     <!-- Create a single component which is the TestService.exe file --> 
     <Component Id="$(var.TestService2.TargetFileName)"> 
     <!-- Copies the TestService.exe file using the project reference preprocessor variables --> 
     <File Id="$(var.TestService2.TargetFileName)" Source="$(var.TestService2.TargetPath)" KeyPath="yes" /> 
     <!-- Remove all files from the INSTALLFOLDER on uninstall --> 
     <RemoveFile Id="RemoveService2" Name="*.*" On="both" /> 
     <!-- Tell WiX to install the Service --> 
     <ServiceInstall Id="Service2Installer" 
     Type="ownProcess" 
     Name="TestService2" 
     DisplayName="$(var.Service2Name)" 
     Description="$(var.Service2Description)" 
     Start="auto" 
     ErrorControl="normal" /> 
     <!-- Tell WiX to start the Service --> 
     <ServiceControl Id="StartService2" Start="install" Stop="both" Remove="uninstall" Name="TestService2" Wait="yes" /> 
     </Component> 
    </DirectoryRef> 
    <!-- Tell WiX to install the files --> 
    <Feature Id="Feature1" Title="TestService1.Setup" Level="1"> 
     <ComponentRef Id="$(var.TestService1.TargetFileName)" /> 
    </Feature> 
    <Feature Id="Feature2" Title="TestService2.Setup" Level="1"> 
     <ComponentRef Id="$(var.TestService2.TargetFileName)" /> 
    </Feature> 
    </Product> 
</Wix> 
관련 문제