Add-in Express 2010 MSI-based web deployment: Managing updates, part 3
This is the third and the final part of my series about ClickTwice – MSI-based web deployment technology introduced in Add-in Express 2010. In the first article of this series I covered the basics of our MSI-based web deployment, and gave you a step-by-step guidance on creating a new setup project. In part 2, we learnt how to publish the application using the MSI-based web deployment. And now we are going to have a close look at managing your application updates.
Managing application updates
When a new version of the software is ready to be published, you need to create a new version of the setup project. All subsequent steps are described in part 2 of the series. However, to activate the self-updating functionality you need to add some code to your application. Here is a sample code that checks for new updates and initiates the updating process.
private void adxRibbonButton1_OnClick(object sender, AddinExpress.MSO.IRibbonControl control, bool pressed) { if (this.IsMSINetworkDeployed() && this.IsMSIUpdatable()) { string updateUrl = this.CheckForMSIUpdates(); if (!String.IsNullOrEmpty(updateUrl)) { if (MessageBox.Show("A new version of the add-in was detected. " + "Would you like to install the update?", this.AddinName, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { string ieFullPath = Path.Combine(Environment.GetFolderPath( Environment.SpecialFolder.ProgramFiles), "Internet Explorer\\iexplore.exe"); this.CreateProcess("\"" + ieFullPath + "\" \"" + updateUrl + "\""); } } } }
The code is based on three methods.
- IsMSINetworkDeployed – returns True if the application was installed via the MSI-based Web deployment feature.
- IsMSIUpdatable – returns True if the user is permitted to update the application. In Vista or Windows 7, it is always True. If the application was installed for all users and the user is not an administrator, the UAC popup will ask for administrator credentials.
- CheckForMSIUpdates – returns an empty string if there are no updates on the server or in the network file share. If a new version of the application is available, the method returns a formatted string: a URL or UNC path; the URL can be a link to setup.exe or the application downloader, or if you set 'Download page for updates' in the Preferences dialog, the method returns the web page URL.
In the sample above, we use the CreateProcess method to launch the update URL. It runs Internet Explorer in the same integrity level as the host application. Of course, you can use your own code to initiate updates on the end-user's PC. E.g. you can use the Process class of the .NET Framework to launch the default browser with the URL provided by the CheckForMSIUpdate method.
Conclusion
ClickOnce is a powerful technology for application deployment. However, it doesn't possess some useful features of the Windows Installer like Multipart wizard, installation of a COM add-in for all users and running custom actions during the installation process. A combination of the Windows Installer and the Add-in Express Web deployment feature empowers the developer with a simple and flexible tool for deploying and updating MSI-based applications via the Internet.
I believe that Add-in Express Web deployment is an excellent means to simplify the deployment of applications written for Microsoft Office and Internet Explorer. Any ideas and suggestions on improving and extending its functionality are the most welcome and we will undoubtedly take all your feednack into consideration when releasing our future builds.
You may also be interested in:
Add-in Express 2010 MSI-based web deployment – ClickTwice, part 1
Add-in Express 2010 MSI-based web deployment: Publishing the application, part 2
9 Comments
In the sample code above, we specified the full path to iexplore.exe (which is the Internet Explorer application) in the CreateProcess method. However, this approach does not work for Internet Explorer 6. In this case you can specify the full path to explorer.exe (which is the Windows Explorer application). Many thanks to Aaron for the suggested workaround!
Hello,
Is it possible to pass arguments to the MSI when using this technique? The equivalent of running the .msi from the command line and adding “thisparam=xxx thatparam=yyy” ?
Thanks in advance for your answer.
Michel
Hi Michel,
It is not supported in the current version of the product. But we will add this feature in subsequent builds.
Hi Sergey,
Thank you for your answer.
Now if I create a .bat file that launches the msi and pass it the appropriate arguments, and deploy it to the server, wouldn’t there be a way to tweak the version_info.xml file so that it runs the .bat file instead of the setup program? Would this be an option?
No, it is not possible. MSI file is hard-coded in the ClickTwice downloader.
I’ve followed these 3 steps for MSI Web Deployment and all seemed good until I went to update. I keep getting “no updates available” even though I have made updates and increased the versions and put the new files on the server.
I feel my issue must be the value returned here: this.CheckForMSIUpdates();
I am running Windows 7 and Office 2010.
Where do I set this so it returns the updateUrl?
Did you update the version_info.xml file on the server?
hello, How can I registry my project with all the functions that I did ? because i create a msi installer and only the ribbonn can see in excell, I don’t know if I a forget something to do
Hello Eddy,
When you register the project, all the functionality should be available with no omissions. What functionality or UI elements are you missing?
Also, you can let Add-in Express generate a new setup project for your add-in.