I’ve been working for some time at automating the InstallShield build process from within an MSBuild script. After a successful attempt using an Exec task along with ISCmdBld.exe, I decided that I really wanted the InstallShield logging included in the MSBuild logging process.
I came across the Microsoft.Sdc tasks project on CodePlex and initially thought it’d work great, but, after a few tries, I discovered it was hardcoded to a very old version of InstallShield.
Then I happened to notice the “InstallShield” folder under the \Program Files\MSBuild folder. In that folder was a 2009 folder and in there were two files:
- InstallShield.targets
- InstallShield.Tasks.dll
Surely, this was what I’d been needing all along!
First step, google “InstallShield.Tasks.DLL”.
I ended up here, with a page detailing all the options for the InstallShield MSBuild task. This is for IS 2009, but there are other pages for IS 2008, etc. Looks like most of the parameters are the same though.
Next, hook up the tasks to my MSBuild project file.
<Project ToolsVersion="3.5" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="swiNumbering">
<!-- Define various properties to use during the build here -->
<PropertyGroup>
<!-- Test for the InstallShield Extensions -->
<InstallShieldTasksPath>$(MSBuildExtensionsPath)\InstallShield\2009\InstallShield.targets</InstallShieldTasksPath>
</PropertyGroup>
<Import Project="$(InstallShieldTasksPath)"/>
This makes the InstallShield task accessible to MSBuild.
Then, just add a target using that task:
<InstallShield.Tasks.InstallShield InstallShieldPath="C:\Program Files\InstallShield\2009 StandaloneBuild\System" Project="@(InstallToBuild)" ProductConfiguration="Package" ReleaseConfiguration="MSI" />
Of course, your values for those parameters will likely be different. The @(InstallToBuild) property points directly to the ISM file you want to build. In my first attempt, I thought I could leave out the InstallShieldPath. Surely the task would look that up from the registry. No dice. You have to have it and it needs to point to your InstallShield System folder or you’ll get an error.
Presto! MSBuild now sees the output of the ISCmdBld process (as evidenced by the nice colored output in the DOS Window when I run MSBuild).
One step closer to complete “Continuous Integration”.