Skip to content

Commit 6b673bf

Browse files
committed
Merged PR 139: Replaced broken v3 override logic with v2 working logic which shold fix #5058
Replaced broken v3 override logic with v2 working logic which shold fix #5058 Related work items: #5058
1 parent 945f647 commit 6b673bf

File tree

1 file changed

+27
-28
lines changed

1 file changed

+27
-28
lines changed

processtemplatetask/vCurrent/importProcess.ps1

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -63,36 +63,35 @@ foreach ($pt in $templates.value)
6363
##########################################
6464
$file = Get-ChildItem $processFile
6565
Write-VstsTaskVerbose $file
66-
Write-VstsTaskVerbose "***RUNNNING OVERIDES****"
67-
Add-Type -AssemblyName System.IO.Compression.FileSystem
68-
$workFolder = [System.IO.Path]::Combine($file.Directory.FullName, "template")
69-
############ UNPACK
70-
if (Test-Path $workFolder)
66+
if ((($overrideProcessGuid -ne $null) -and ($overrideProcessGuid -ne "")) -or (($overrideProcessName -ne $null) -and ($overrideProcessName -ne "")))
7167
{
72-
[System.IO.Directory]::Delete($workFolder, $true)
73-
}
74-
[System.IO.Compression.ZipFile]::ExtractToDirectory($file, $workFolder)
75-
############ CHANGE
76-
$processFile = "$workFolder\ProcessTemplate.xml"
77-
$processFileXml = [xml](get-content $processFile)
78-
if (($overrideProcessGuid -ne $null) -and ($overrideProcessGuid -ne ""))
79-
{
80-
$guidXml = $processFileXml.ProcessTemplate.metadata.version.Attributes.GetNamedItem("type")
81-
$guid = $guidXml.'#text'
82-
Write-VstsTaskVerbose "Current GUID is $guid and we are replacing it with $overrideProcessGuid before upload"
83-
$guidXml.'#text' = $overrideProcessGuid
84-
$processFileXml.Save([string]$processFile)
85-
}
86-
if (($overrideProcessName -ne $null) -and ($overrideProcessName -ne ""))
87-
{
88-
$nameXML = $processFileXml.ProcessTemplate.metadata.name
89-
Write-VstsTaskVerbose "Current Name of the Process is $nameXML and we are replacing it with $overrideProcessName before upload"
90-
$nameXML = $overrideProcessName
91-
$processFileXml.Save([string]$processFile)
68+
Write-VstsTaskVerbose "***RUNNNING OVERIDES****"
69+
Add-Type -AssemblyName System.IO.Compression.FileSystem
70+
$workFolder = [System.IO.Path]::Combine($file.Directory.FullName, "template")
71+
if (Test-Path $workFolder)
72+
{
73+
[System.IO.Directory]::Delete($workFolder, $true)
74+
}
75+
[System.IO.Compression.ZipFile]::ExtractToDirectory($file, $workFolder)
76+
$processFile = "$workFolder\ProcessTemplate.xml"
77+
$xml = [xml](get-content $processFile)
78+
if (($overrideProcessGuid -ne $null) -and ($overrideProcessGuid -ne ""))
79+
{
80+
$guidXml = $xml.ProcessTemplate.metadata.version.Attributes.GetNamedItem("type")
81+
$guid = $guidXml.'#text'
82+
Write-VstsTaskVerbose "Current GUID is $guid and we are replacing it with $overrideProcessGuid before upload"
83+
$guidXml.'#text' = $overrideProcessGuid
84+
}
85+
if (($overrideProcessName -ne $null) -and ($overrideProcessName -ne ""))
86+
{
87+
$nameXML = $xml.ProcessTemplate.metadata.name
88+
Write-VstsTaskVerbose "Current Name of the Process is $nameXML and we are replacing it with $overrideProcessName before upload"
89+
$xml.ProcessTemplate.metadata.name = $overrideProcessName
90+
}
91+
$xml.Save([string]$processFile)
92+
[System.IO.File]::Delete($file)
93+
[System.IO.Compression.ZipFile]::CreateFromDirectory($workFolder,$file)
9294
}
93-
############ REPACK
94-
[System.IO.File]::Delete($file)
95-
[System.IO.Compression.ZipFile]::CreateFromDirectory($workFolder,$file)
9695
##########################################
9796
# Upload templates
9897
##########################################

0 commit comments

Comments
 (0)