Hi there, it’s me again. This time, we’re looking at Powershell, which is mostly the same story as previous efforts with other scripting engines.
Notable differences are how the Const/Enum’s are handled, using the New-Variable scriptlet to make a read-only variable, as well as the usage of the Item function call.
ISWiComponents
This example illustrates getting a specific feature from the ISWiFeatures collection, and using it to set component properties, and then saving the project.
New-Variable -Option constant -Name rfsLocal -Value 0
New-Variable -Option constant -Name rfsSource -Value 1
New-Variable -Option constant -Name rfsOptional -Value 2
$m_ISWiProj = new-object -comobject IswiAuto17.ISWiProject
$strFile = “C:InstallShield 2011 ProjectsMY 64 bit Project.ism”
$m_ISWiProj.OpenProject($strFile)
$m_Feature = $m_ISWiProj.ISWiFeatures.Item(“MyApplication”)
foreach ($m_Component in $m_Feature.ISWiComponents)
{
$m_Component.RemoteInstallation = $rfsSource
}
$m_ISWiProj.SaveProject()
$m_ISWiProj.CloseProject()
ISWiFeatures
This example illustrates iterating through root-level features and components.
$m_ISWiProj = new-object -comobject IswiAuto17.ISWiProject
$strFile = “C:InstallShield 2011 ProjectsMY 64 bit Project.ism”
$m_ISWiProj.OpenProject($strFile)
$strProject = “”
Foreach ($m_Feature in $m_ISWiProj.ISWiFeatures)
{
$strProject = $strProject + “Feature: ” + $m_Feature.Name + “`n”
$strProject = $strProject + “Components: ”
Foreach ($m_Component in $m_Feature.ISWiComponents)
{
$strProject = $strProject + $m_Component.Name + ” ”
}
$strProject = $strProject + “`n”
}
Write-Host $strProject
$m_ISWiProj.CloseProject()
Hi.
I’m not sure that you calling a similar powershell script file in TFS2010, the part of script file has the following
powershell code:
$oneISProject = New-Object -com ISWiAuto15.ISWiProject
$IsmFileStatus = $oneISProject.OpenProject($ISProjectFile)
echo “File open status : $($IsmFileStatus)”
$oneISProject.ProductVersion = $version
$q = $oneISProject.SaveProject()
echo “Project saved status : $($IsmFileStatus)”
$q= $oneISProject.CloseProject()
echo “Project closed status : $($IsmFileStatus)”
#[System.Runtime.Interopservices.Marshal]::ReleaseComObject($oneISProject)
$oneISProject = $null
$ ISProjectFile is my *.ism file
After calling the script, powershell script can not end .also TFS2010’s build definition can not end it. when I remove this
part code from the ps script file, it work.
This problem has troubled me for a long time, hoping to get some clues.
My system environment:
windows2003 enterprise server sp2
TFS2010
installshield 2009 Premier sp1
Thanks,
deepstar
Very Useful information.
@Cary Roys,
Can you please also give an example of how to modify the General Summary Info (Title, Summary etc.. fields) via Powershell?
Thanks
John
What is “MyApplication” here? Is that the name of the feature?
If I provide the name of my feature in this place, I do not receive the handle to the project.
Please help.