开发者

WPF deployment project: trigger another msi installation during commit stage of the original installer

I am having a WPF project and created a deployment project. I was able to get the installer running and it works fine. Now during the commit stage of the application, I want to trigger another installation. I tried creating a custom action and added below command in the customactiondata field.

msiexec.exe /i "[SOURCEDIR]\App.msi" /qb

W开发者_如何学JAVAhen I run the application, I get a help window displaying the MSI options. Any idea why the installer is not triggered.

-- Bala


Bala,

When you say you would like to have App.msi install after your install, it makes me ask if you control this App.msi or if you are using someone else's installer. The reason I am wondering this is because if you're in control of the App.msi, I would recommend changing that into a merge module and adding the output of this merge module to your installer project. This would be the simplest plan of attack if you're the writer of the App.msi. However, if you just want to install someone else's msi after yours is finished, you're on the right track. Basically the reason your getting the MSI option dialog is because something isn't quite formatted correctly. My guess here is that your custom action isn't calling out correctly to the MSIEXEC.EXE and thus causing the help options dialog to pop up. Without your source code I cannot be sure on what specifically is wrong, I can only show you an example of how I got it to work. My solution is as follows:

First, let's look at the solution if you do control the App.msi, and can convert it into a merge module. Here are the steps to do that:

  1. Create the merge module. Basically you just take the stuff you were doing in the MSI and move it to the Merge Module, they are basically the same as far as how Visual Studio displays them to you.
  2. Create your MSI project.
  3. Add the output of your merge module into your MSI.
  4. Compile and install your MSI.

Now for the case that you don't control the App.msi, here is what you need to do:

  1. Create a class library project, name it whatever you'd like. This project will contain the logic for calling out to your external msi file.
  2. Add a new item to this project of type Installer Class, again name this class whatever you'd like.
  3. Delete the generated Class1.vb (.cs) file as it is not required.
  4. Create your WPF project (or add your existing WPF project).
  5. Create a Setup Project, again naming whatever you'd like.
  6. In the class project, right click on the installer class, and view the code.
  7. Add code to your class for Install and Commit (See Figure 1 Below):
  8. In the installer project, add the primary output from the WPF application, and the class library.
  9. Add your App.msi file to the installer project.
  10. Open up the custom actions, right click on the custom actions root node, and click on "Add Custom Action...".
  11. Navigate to the primary output from your wpf project, click OK.
  12. Add the primary output from the class library in the same way.
  13. Select the primary output from the class library under the install node, and view its properties.
  14. Under the CustomActionData field, type this:
    /OtherMSIPath="[TARGETDIR]\App.msi"
  15. Verify that InstallerClass field is set to True.
  16. Build and Install your application.

Figure 1:

 Public Overrides Sub Install(ByVal stateSaver As System.Collections.IDictionary)
  MyBase.Install(stateSaver)

  stateSaver.Add("OtherMSIPath", Context.Parameters("OtherMSIPath"))
 End Sub

 Public Overrides Sub Commit(ByVal savedState As System.Collections.IDictionary)
  MyBase.Commit(savedState)
  System.Diagnostics.Process.Start("MSIEXEC.EXE", "/i """ & savedState.Item("OtherMSIPath").ToString & """ /qb")
 End Sub

I've added this to the source code for the sample answer to this question to Google Code for you to download. You can checkout this example here using a subversion client.

I hope this helps,

Thanks!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜