Skip to content

Commit efa37ed

Browse files
committed
Replace text to ensure converted InstallPhase declarations and MARKS match the style of the v4 template
1 parent 22be41a commit efa37ed

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/PSAppDeployToolkit.Tools/Public/Convert-ADTDeployment.ps1

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,13 @@ function Convert-ADTDeployment
273273
$end = $functionAst.Body.Extent.EndOffset
274274
$scriptContent = $tempScriptAst.Extent.Text
275275
$newScriptContent = ($scriptContent.Substring(0, $start) + $ifClause.Item2.Extent.Text + $scriptContent.Substring($end)).Trim()
276+
277+
# Fix to make converted InstallPhase declarations from v3 match the syntax used in the v4 template
278+
$newScriptContent = $newScriptContent -replace '\[String\]\$adtSession.InstallPhase = ''(Pre-|Post-)(?:Installation|Uninstallation|Repair)''', '$adtSession.InstallPhase = "$1$($adtSession.DeploymentType)"' -replace '\[String\]\$adtSession.InstallPhase = ''(?:Installation|Uninstallation|Repair)''', '$adtSession.InstallPhase = $adtSession.DeploymentType'
279+
280+
#Fix to convert MARK labels to match v4 format
281+
$newScriptContent = $newScriptContent.Replace('##* MARK: PRE-INSTALLATION', '## MARK: Pre-Install').Replace('##* MARK: INSTALLATION', '## MARK: Install').Replace('##* MARK: POST-INSTALLATION', '## MARK: Post-Install').Replace('##* MARK: PRE-UNINSTALLATION', '## MARK: Pre-Uninstall').Replace('##* MARK: UNINSTALLATION', '## MARK: Uninstall').Replace('##* MARK: POST-UNINSTALLATION', '## MARK: Post-Uninstall').Replace('##* MARK: PRE-REPAIR', '## MARK: Pre-Repair').Replace('##* MARK: REPAIR', '## MARK: Repair').Replace('##* MARK: POST-REPAIR', '## MARK: Post-Repair')
282+
276283
Set-Content -Path $outputScriptPath -Value $newScriptContent -Encoding UTF8
277284
}
278285
}

0 commit comments

Comments
 (0)