WiXの(2.0)を使用して複数ファイルNTサービスのインストール
-
13-09-2019 - |
質問
どのように私はWiXの中にいくつかの追加のファイルとサービスをインストールして、実際のサービスのEXEファイルでどのファイルを定義できますか?
シナリオ:私は、単一のEXEファイルだったサービスがあったが、このコードでのWiXでのWindows NTサービスとしてインストールします:
<Component Id='InstallMyServiceComponent' Guid='{....}' DiskId='1'>
<File Id='InstallMyServiceEXEFile' LongName='MyService.exe'
Name='MyServ.exe' src='MyService/bin/release/MyService.exe' KeyPath='yes'/>
<ServiceInstall Id='InstallMyService' Name='MyService' Description='My Service'
ErrorControl='normal' Start='auto' Type='ownProcess' Vital='yes' />
<ServiceControl Id='UninstallMyService' Name='MyService' Remove='uninstall'
Wait='yes' />
</Component>
<Component Id='RunMyServiceComponent' Guid='.......'>
<ServiceControl Id='RunMyService' Name='MyService' Start='install'
Stop='uninstall' Wait='no' />
</Component>
と私はその後、インストールして、必要に応じてこのサービスを開始できるようになる機能を持っています。
さて、私の問題がある - 今、私のサービスが成長していない、単一のEXEは、もはや単一のEXEである - それは、複数のファイル、EXE、DLL、およびいくつかのサポートファイルです。
。しかし、どのように私は??今それをインストールすることができます。
私はすべてのファイルとコンポーネントを持つようにしようとした。
<Component Id="MyService" Guid="......" DiskId="1">
<File Id="fileMyService_framework_dll" LongName="Framework.dll"
Name="Framewrk.DLL" src="MyService\Framework.dll" />
<File Id="fileMyService_dal_dll" LongName="MyServiceDAL.dll"
Name="SrvcDAL.DLL" src="MyService\ServiceDAL.dll" />
<File Id="fileMyService_helpers_dll" LongName="Helpers.dll"
Name="Helpers.DLL" src="MyService\Helpers.dll" />
<File Id="fileMyService_exe" LongName="MyService.exe"
Name="MySrv.EXE" src="MyService\MyService.exe" />
</Component>
まず、私はちょうどこのコンポーネントにServiceInstallとに、Servicecontrolタグを追加しようとしました。
<Component Id="MyService" Guid="......" DiskId="1">
<File Id="fileMyService_framework_dll" LongName="Framework.dll"
Name="Framewrk.DLL" src="MyService\Framework.dll" />
<File Id="fileMyService_dal_dll" LongName="MyServiceDAL.dll"
Name="SrvcDAL.DLL" src="MyService\ServiceDAL.dll" />
<File Id="fileMyService_helpers_dll" LongName="Helpers.dll"
Name="Helpers.DLL" src="MyService\Helpers.dll" />
<File Id="fileMyService_exe" LongName="MyService.exe"
Name="MySrv.EXE" src="MyService\MyService.exe" />
<ServiceInstall Id='InstallMyService' Name='MyService'
Description='My Service' ErrorControl='normal' Start='auto'
Type='ownProcess' Vital='yes' />
<ServiceControl Id='UninstallMyService' Name='MyService'
Remove='uninstall' Wait='yes' />
</Component>
しかし、その後、私の「Framework.dllが」作成中のサービスのためのソース・パスとして設定されます........
だから、私はServiceInstallを使用して、実際にサービスをインストールするために第2のコンポーネントを作成しようと思いましたし、私はちょうどFileRefを使用して、そのサービスのEXEファイルを参照したい - それは(少なくとも、Wix2に)存在していないようです。
<Component Id='InstallMyServiceComponent' Guid='{....}' DiskId='1'>
<FileRef Id='fileMyService_exe' KeyPath='yes'/>
<ServiceInstall Id='InstallMyService' Name='MyService'
Description='My Service' ErrorControl='normal' Start='auto'
Type='ownProcess' Vital='yes' />
<ServiceControl Id='UninstallMyService' Name='MyService'
Remove='uninstall' Wait='yes' />
</Component>
だから、 - ?? <(ファイルのコンポーネントのリストからだけではなく、任意のファイル)正しいEXEファイルをピックアップするNTサービスのインストールを必要なすべてのファイルをインストールし、まだ取得するん貧しいWiXの著者ちゃ何です/ P>
マルク
解決
ServiceInstall要素はServiceInstallがであるコンポーネントの「キーパス」を指していることになります。デフォルトでのWiXツールセットがキーパスとしてあなたのコンポーネントの最初のファイルまたはのRegistryKey要素をピックアップ。あなたのコンポーネントにファイルを追加すると、リストの一番上にある.dllには、キーパスとなっています。
一般的に、より小さなコンポーネントは、大きなものよりも優れています。だから、より良い解決策は、別のコンポーネントで、あなたのDLLを置くことであろう。次に、.exeファイルの要素と同じコンポーネントでServiceInstall要素を残すことができます。つまり、すべてがとてもきれいになります。
あなたが一緒にグループ化された「サービス」をしたい場合は、あなたがのComponentGroup要素を作成すると.exeと.dllコンポーネントにComponentRefsを置くことができます。今あなたがフィーチャー/ ComponentGroupRefから参照することができ、単一のものを持っています。