Building UCMA 2.0 Installers
When building an application using UCMA 2.0, you might encounter Error 1001. This is common to any Setup projects built for the x64 platform using Visual Studio 2008. This article highlights this problem because developers using UCMA 2.0 and creating a Setup for their UCMA applications are likely to encounter it. There is a simple solution that can be automated so you can forget about it.
Author: Rui Maximo
Publication date: November 2009
Product version: Office Communications Server 2007 R2
If you want to build an application by using UCMA 2.0, you will need to build your application for the x64 platform because that is the only supported platform. When you package your application for customer use complete with an installer, you are likely to encounter the error shown in Figure 1 when you run your MSI. For this example, I edited the error message to make it more generic. The placeholders, <name> and <value>, will have values that are specific to your application. The Error 1001 error message is rather obscure, and it took some researching to determine the root cause.
Figure 1. Error installing MSI for x64 platform
I discovered that this problem is not specific to UCMA 2.0, but is common to any Setup projects that are built for the x64 platform using Visual Studio 2008. However, I am highlighting this problem because developers using UCMA 2.0 and creating a Setup for their UCMA applications are likely to encounter this problem. There is a simple solution that can be automated so you can forget about it.
There are two parts to this solution. The first part takes advantage of a VBScript written by Steve Michelotti that I found by searching the Web using Bing.com. This script is located at http://geekswithblogs.net/michelotti/archive/2007/03/17/109091.aspx. The second part is automating the process of running this script during the post-build process in Visual Studio 2008 so that you do not have to run it manually.
Copy and paste the following script into a file that is named fixmsi.vbs. You can select a different name. Just make sure that you reflect this change in the PostBuildEvent field, which is explained in more detail later in this article.
' ' Add to PostBuildEvent property of Deployment (setup) Project: ' ' cscript.exe "$(ProjectDir)fixmsi.vbs" "$(BuiltOutputPath)" ' ' Author: http://geekswithblogs.net/michelotti/archive/2007/03/17/109091.aspx ' Option Explicit On Error Resume Next Const msiViewModifyInsert = 1 Const msiViewModifyUpdate = 2 Const msiViewModifyAssign = 3 Const msiViewModifyReplace = 4 Const msiViewModifyDelete = 6 If (WScript.Arguments.Count = 0) Then Msgbox("No command line argument specified for MSI location. Please try again.") Wscript.Quit 1 Else AdjustInstallUtil() End If public sub AdjustInstallUtil() On Error Resume Next dim msiInstance : msiInstance = WScript.Arguments.Item(0) dim installer : Set installer = CreateObject("WindowsInstaller.Installer") dim installerDb : Set installerDb = installer.OpenDatabase(cstr(msiInstance), 1) dim sqlCommand : sqlCommand = "SELECT * FROM Binary WHERE `Name`='InstallUtil'" dim view : Set view = installerDb.OpenView(sqlCommand) view.Execute() dim record : Set record = view.Fetch() If Not record Is Nothing Then const dataCol = 2 record.SetStream dataCol, "C:\Windows\Microsoft.NET\Framework64\v2.0.50727\InstallUtilLib.dll" view.Modify msiViewModifyUpdate, record installerDb.Commit End IF 'clean up Set installerDb = Nothing Set view = Nothing Set installer = Nothing 'Error Handling If Err.number > 0 Then Msgbox("Error while adjusting x64 InstallUtilLib: " & Err.Description & ": " & Err.Source & ": " & Err.number) End If end sub
Next, automate the process of running this script after Visual Studio 2008 builds your Setup project by doing the following:
From Solution Explorer, select your installer node that was created by the Setup Project, and then view Properties. This displays the Deployment Project Properties as shown in Figure 2.
Figure 2. Setup Project Properties
For clarity, all fields except the relevant ones for this discussion were removed. That does not mean they are not needed. The intent is to highlight the ones that are required to automatically build your installer for the x64 platform.
In the PostBuildEvent field, specify the script that you want to run. Because the VBScript, fixmsi.vbs, is located in the Setup directory, the environment variable $(ProjectDir) can be used to specify the path of the script "$(ProjectDir)fixmsi.vbs". The VBScript changes the output, "$(BuiltOutputPath)", which is the resulting MSI file. The complete command is as follows:
cscript.exe "$(ProjectDir)fixmsi.vbs" "$(BuiltOuputPath)"
In the RunPostBuildEvent field, specify the condition when to run the PostBuildEvent. In our case, we want to run the VBScript only when the build process is successful, "On successful build".
In the TargetPlatform field, specify the platform for which the Setup project will be built. Because applications built using UCMA 2.0 target the x64 platform, and this problem only exists for this platform, this field should specify x64.
Setting these three fields automatically runs the fixmsi.vbs script after the MSI is built. This is convenient because it avoids the step of having to run the script manually after Visual Studio 2008 finishes building your Setup project. Frequently, this manual step is forgotten. Giving customers a broken Setup just does not give a good first impression.
Office Communications Server Developer Resources
Office Communications Developer Center http://msdn.microsoft.com/ocdev
Unified Communications Developer Center http://go.microsoft.com/fwlink/?LinkID=133626
Communications Server 2007 R2 Server SDK Documentation http://go.microsoft.com/fwlink/?LinkID=133566
MSDN Documentation portal for Communications Server 2007 R2 http://go.microsoft.com/fwlink/?LinkID=133592
Communicator 2007 and Communicator 2007 R2 documentation http://go.microsoft.com/fwlink/?LinkID=133593
MSDN Office http://twitter.com/MSDN_Office
Office Communications Server 2007 R2 http://twitter.com/DrRez
- GotUC.Net developer resource for Office Communications Server http://gotuc.net
Office Communications Server http://go.microsoft.com/fwlink/?LinkId=177722
Unified Communications Integration http://go.microsoft.com/fwlink/?LinkId=177723
Office Communicator http://go.microsoft.com/fwlink/?LinkId=177724
Unified Communications Managed API SDK Forum http://go.microsoft.com/fwlink/?LinkId=177725