したい:
- ディレクトリを作成します。
- ポイント 1 からいくつかのファイルをディレクトリにインストールする別のインストーラ (MSI ではない) を実行します。
- ポイント 2 でインストールしたファイルの一部を置き換えます。
これらはすべて、WiX (Windows Installer XML) を使用して作成したインストールで実行する必要があります。
以下に、私の WiX ファイルの重要な部分があります。問題は、このインストールで必要に応じてファイルが置き換えられないことです。ファイルを削除するには、Property 属性を指定して RemoveFile 要素を使用します。これは、インストーラー データベースにないファイルを削除する唯一の方法 (カスタム アクション内でコードを記述する場合を除きます。これは望ましくありません) であるためです。
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="ManufacturerDirectory" Name="$(var.Manufacturer)">
<Directory Id="ProductDirectory" Name="$(var.ProductName)">
<Directory Id="SubDirectory" Name="$(var.SubDirectoryName)">
</Directory>
</Directory>
</Directory>
</Directory>
</Directory>
<!-- Create the directory at point 1. -->
<Component
Id="RemoveOldData" Guid="..." KeyPath="yes"
Directory="ManufacturerDirectory">
<CreateFolder Directory="ProductDirectory" />
</Component>
<!-- Following two components replace the file(s) (point 3). -->
<Component
Id="RemoveOldData" Guid="..."
Directory="SubDirectory" KeyPath="yes"
>
<RemoveFile
Id="Remove_MyFile.exe" On="install"
Property="SUBDIRECTORYPROPERTY" Name="MyFile.exe" />
</Component>
<Component
Id="FilesToReplace" Guid="..."
Directory="SubDirectory">
<File
Id="MyFile.exe" Vital="yes" KeyPath="yes" DiskId="1"
Source="$(var.SourcePath)MyFile.exe" Name="MyFile.exe"
/>
</Component>
<Binary Id="WiseInstallation" SourceFile="$(var.WiseSourcePath)..." />
<!-- Launch Wise installation at point 2. -->
<CustomAction
Id="LaunchWiseInstallation"
BinaryKey="WiseInstallation"
ExeCommand=""
Return="check"
Execute="deferred"
Impersonate="yes" />
<!-- Following custom action assigns a property.
This needs to remove files that are not in the current installer database.
To do it, the Property attribute of the RemoveFile element is needed. -->
<CustomAction
Id="Assign_SUBDIRECTORYPROPERTY"
Property="SUBDIRECTORYPROPERTY"
Value="[SubDirectory]" />
<InstallExecuteSequence>
<Custom Action="Assign_SUBDIRECTORYPROPERTY" After="InstallInitialize" >
NOT Installed</Custom>
<Custom Action="LaunchWiseInstallation" After="CreateFolders" >
NOT Installed</Custom>
<RemoveFiles Sequence="3720"/>
<RemoveFolders Sequence="3730"/>
</InstallExecuteSequence>
Orca のビューからの InstallExecuteSequence:
- ValidateProductID 700
- CostInitialize 800
- ファイルコスト 900
- CostFinalize 1000
- インストール検証 1400
- インストール初期化 1500
- Assign_SUBDIRECTORYPROPERTY 1501
- プロセスコンポーネント 1600
- UnpublishFeatures 1800
- レジストリ値の削除 2600
- ショートカットの削除 3200
- フォルダ作成 3700
- LaunchWiseインストール 3701
- ファイルの削除 3720
- フォルダーの削除 3730
- インストールファイル 4000
- ショートカットの作成 4500
- 書き込みレジストリ値 5000
- 登録ユーザー 6000
- RegisterProduct 6100
- パブリッシュ機能 6300
- パブリッシュ製品 6400
- インストール完了 6600
インストールログファイルも確認しました:
- SUBDIRECTORYPROPERTY プロパティが適切に割り当てられました。
- InstallExecuteSequence が適切に実行されました。
- インストールはエラーなしで完了しました。
しかし、ファイルが削除されたり、置き換えられたりしたことはありません!