# Copy the script below into the 'Script' window of the DevOps PowerShell task # The DevOps PowerShell task should be Version2 and its Type set to Inline. # InstallShield SAB 2018 must be installed on the build PC. # Required for ScriptBlock definition [CmdletBinding()] # Place all code in a script block so we can run it in 32 bit mode (required to create automation COM object) $ScriptBlock = { # Assume we fail $returnCode = 1 # Define our variables $ProjectPath = "" # The name of the product configuration folder in the projects 'Releases' view $InstallerConfiguration = "Full" # The name of the Release in the projects 'Releases' view $InstallerRelease = "Release" # DevOps pipeline source directory $SourceRootPath = $Env:BUILD_SOURCESDIRECTORY Write-Host "The source path is: "$SourceRootPath $InstallerProjectFilename = Join-Path $SourceRootPath $ProjectPath Write-Host "The project filename is: "$InstallerProjectFilename # DevOps pipeline build number (see Build number format in Pipeline Options) $BuildVersion = $Env:BUILD_BUILDNUMBER Write-Host "The build version is: "$BuildVersion try { # Create the 2018 Installshield COM object $installer = New-Object -com ISWiAuto24.ISWiProject Write-Host "Installer COM object created" $installer.OpenProject($InstallerProjectFilename) Write-Host "Opened the Installer project" $ProductGUID = $installer.GenerateGUID() Write-Host "Created ProductCode: " $ProductGUID $installer.ProductCode = $ProductGUID Write-Host "Set ProductCode: " $installer.ProductCode $installer.ProductVersion = $BuildVersion Write-Host "Set ProductVersion: " $installer.ProductVersion # Find the Product Configuration which holds the release that is built $ProductConfig = $installer.ISWiProductConfigs.Item($InstallerConfiguration) if($ProductConfig) { Write-Host "Found ProductConfiguration called: " $InstallerConfiguration # Find the Release $ReleaseItem = $ProductConfig.ISWiReleases.Item($InstallerRelease) if($ReleaseItem) { Write-Host "Found the Release called: " $InstallerRelease Write-Host "Starting the build... " $ReleaseItem.Build() Write-Host "Built" # Set the return code based on the error count, i.e. if there were no errors the return code will be 0 $returnCode = $ReleaseItem.BuildErrorCount Write-Host "Build completed with " $returnCode "errors" } } # Close the project $installer.CloseProject() Write-Host "Project closed" } catch { Write-Error "Exception details-: $($_)" } finally { if($installer) { [System.Runtime.Interopservices.Marshal]::ReleaseComObject($installer) } } # Finish by returning error code (0 is success) return $returnCode } Write-Host "Starting installer build job which will take some time..." # Execute the ScriptBlock as a 32bit process (required because create COM object failed on 64bit build PC) $result = Start-Job -ScriptBlock $ScriptBlock -Authentication Default -RunAs32 | Wait-Job | Receive-Job if($result -eq 0) { Write-Host "Application Installer built successfully" } else { Write-Host "Failed to built Application Installer" } exit $result