diff --git a/utilities/tools/ConvertTo-ARMTemplate.ps1 b/utilities/tools/ConvertTo-ARMTemplate.ps1 index bfc5ee75a3..ed3150bef3 100644 --- a/utilities/tools/ConvertTo-ARMTemplate.ps1 +++ b/utilities/tools/ConvertTo-ARMTemplate.ps1 @@ -66,13 +66,15 @@ if ($ConvertChildren) { #region Remove existing deploy.json files Write-Verbose 'Remove existing deploy.json files' -$JsonFilesToRemove = Get-ChildItem -Path $armFolderPath -Filter 'deploy.json' -Recurse -Force -File -Write-Verbose "Remove existing deploy.json files - Remove [$($JsonFilesToRemove.count)] file(s)" -if ($PSCmdlet.ShouldProcess("[$($JsonFilesToRemove.count)] deploy.json files(s) in path [$armFolderPath]", 'Remove-Item')) { - $JsonFilesToRemove | Remove-Item -Force +if (Test-Path -Path (Join-Path -Path $armFolderPath -ChildPath 'deploy.bicep')) { + $JsonFilesToRemove = Get-ChildItem -Path $armFolderPath -Filter 'deploy.json' -Recurse -Force -File + Write-Verbose "Remove existing deploy.json files - Remove [$($JsonFilesToRemove.count)] file(s)" + if ($PSCmdlet.ShouldProcess("[$($JsonFilesToRemove.count)] deploy.json files(s) in path [$armFolderPath]", 'Remove-Item')) { + $JsonFilesToRemove | Remove-Item -Force + } + Write-Verbose 'Remove existing deploy.json files - Done' } -Write-Verbose 'Remove existing deploy.json files - Done' #endregion #region Convert bicep files to json @@ -173,29 +175,33 @@ if (-not $SkipPipelineUpdate) { # GitHub workflow files $ghWorkflowFolderPath = Join-Path -Path $rootPath -ChildPath '.github\workflows' - $ghWorkflowFilesToUpdate = Get-ChildItem -Path $ghWorkflowFolderPath -Filter 'ms.*.yml' -File -Force - Write-Verbose ('Update workflow files - Processing [{0}] file(s)' -f $ghWorkflowFilesToUpdate.count) - if ($PSCmdlet.ShouldProcess(('[{0}] ms.*.yml file(s) in path [{1}]' -f $ghWorkflowFilesToUpdate.Count, $ghWorkflowFolderPath), 'Set-Content')) { - # parallelism is not supported on GitHub runners - #$ghWorkflowFilesToUpdate | ForEach-Object -ThrottleLimit $env:NUMBER_OF_PROCESSORS -Parallel { - $ghWorkflowFilesToUpdate | ForEach-Object { - $content = $_ | Get-Content - $content = $content -replace 'templateFilePath:(.*).bicep', 'templateFilePath:$1.json' - $_ | Set-Content -Value $content + if (Test-Path -Path $ghWorkflowFolderPath) { + $ghWorkflowFilesToUpdate = Get-ChildItem -Path $ghWorkflowFolderPath -Filter 'ms.*.yml' -File -Force + Write-Verbose ('Update workflow files - Processing [{0}] file(s)' -f $ghWorkflowFilesToUpdate.count) + if ($PSCmdlet.ShouldProcess(('[{0}] ms.*.yml file(s) in path [{1}]' -f $ghWorkflowFilesToUpdate.Count, $ghWorkflowFolderPath), 'Set-Content')) { + # parallelism is not supported on GitHub runners + #$ghWorkflowFilesToUpdate | ForEach-Object -ThrottleLimit $env:NUMBER_OF_PROCESSORS -Parallel { + $ghWorkflowFilesToUpdate | ForEach-Object { + $content = $_ | Get-Content + $content = $content -replace 'templateFilePath:(.*).bicep', 'templateFilePath:$1.json' + $_ | Set-Content -Value $content + } } } # Azure DevOps Pipelines $adoPipelineFolderPath = Join-Path -Path $rootPath -ChildPath '.azuredevops\modulePipelines' - $adoPipelineFilesToUpdate = Get-ChildItem -Path $adoPipelineFolderPath -Filter 'ms.*.yml' -File -Force - Write-Verbose ('Update Azure DevOps pipeline files - Processing [{0}] file(s)' -f $adoPipelineFilesToUpdate.count) - if ($PSCmdlet.ShouldProcess(('[{0}] ms.*.yml file(s) in path [{1}]' -f $adoPipelineFilesToUpdate.Count, $adoPipelineFolderPath), 'Set-Content')) { - # parallelism is not supported on GitHub runners - #$adoPipelineFilesToUpdate | ForEach-Object -ThrottleLimit $env:NUMBER_OF_PROCESSORS -Parallel { - $adoPipelineFilesToUpdate | ForEach-Object { - $content = $_ | Get-Content - $content = $content -replace 'templateFilePath:(.*).bicep', 'templateFilePath:$1.json' - $_ | Set-Content -Value $content + if (Test-Path -Path $adoPipelineFolderPath) { + $adoPipelineFilesToUpdate = Get-ChildItem -Path $adoPipelineFolderPath -Filter 'ms.*.yml' -File -Force + Write-Verbose ('Update Azure DevOps pipeline files - Processing [{0}] file(s)' -f $adoPipelineFilesToUpdate.count) + if ($PSCmdlet.ShouldProcess(('[{0}] ms.*.yml file(s) in path [{1}]' -f $adoPipelineFilesToUpdate.Count, $adoPipelineFolderPath), 'Set-Content')) { + # parallelism is not supported on GitHub runners + #$adoPipelineFilesToUpdate | ForEach-Object -ThrottleLimit $env:NUMBER_OF_PROCESSORS -Parallel { + $adoPipelineFilesToUpdate | ForEach-Object { + $content = $_ | Get-Content + $content = $content -replace 'templateFilePath:(.*).bicep', 'templateFilePath:$1.json' + $_ | Set-Content -Value $content + } } }