Tasks/Tasks.XmlConfigurations.ps1
#region Copyright & License # Copyright © 2012 - 2021 François Chabot # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #endregion Set-StrictMode -Version Latest # Synopsis: Apply XML configuration customizations task Deploy-XmlConfigurations ` Apply-XmlConfigurations, ` Invoke-XmlConfigurationActions # Synopsis: Revert XML configuration customizations task Undeploy-XmlConfigurations ` Revert-XmlConfigurations, ` Invoke-XmlUnconfigurationActions # Synopsis: Apply XML configuration specifications task Apply-XmlConfigurations { $Resources | ForEach-Object -Process { Write-Build DarkGreen $_.Path Get-ConfigurationSpecification -Path $_.Path -ConfigurationFileResolvers $([Be.Stateless.BizTalk.Dsl.Configuration.Resolvers.BizTalkConfigurationFileResolverStrategy]::new()) | Merge-ConfigurationSpecification -CreateBackup -CreateUndo } } # Synopsis: Apply XML configuration actions task Invoke-XmlConfigurationActions { $Resources | ForEach-Object -Process { $_ } -PipelineVariable xca | ForEach-Object -Process { Write-Build DarkGreen $xca.Path switch ($xca.Action) { 'Append' { Add-ConfigurationElement -ConfigurationFile $xca.Path -XPath $xca.XPath -Name $xca.Name -Attributes $xca.Attributes } 'Update' { Set-ConfigurationElement -ConfigurationFile $xca.Path -XPath $xca.XPath -Attributes $xca.Attributes } 'Delete' { Remove-ConfigurationElement -ConfigurationFile $xca.Path -XPath $xca.XPath } default { throw "Unknown XML configuration action $($xca.Action)." } } } } # Synopsis: Remove XML configuration specifications task Revert-XmlConfigurations -If { -not $SkipUndeploy } { $Resources | ForEach-Object -Process { Get-ChildItem -Path "$($_.Path).*.undo" -File | Sort-Object -Descending | ForEach-Object -Process { Write-Build DarkGreen $_ Get-ConfigurationSpecification -Path $_ -ConfigurationFileResolvers $([Be.Stateless.BizTalk.Dsl.Configuration.Resolvers.BizTalkConfigurationFileResolverStrategy]::new()) | Merge-ConfigurationSpecification -CreateBackup Remove-Item -Path $_ -Force } } } # Synopsis: Apply XML unconfiguration actions task Invoke-XmlUnconfigurationActions { $Resources | ForEach-Object -Process { $_ } -PipelineVariable xca | ForEach-Object -Process { Write-Build DarkGreen $xca.Path switch ($xca.Action) { 'Append' { Add-ConfigurationElement -ConfigurationFile $xca.Path -XPath $xca.XPath -Name $xca.Name -Attributes $xca.Attributes } 'Update' { Set-ConfigurationElement -ConfigurationFile $xca.Path -XPath $xca.XPath -Attributes $xca.Attributes } 'Delete' { Remove-ConfigurationElement -ConfigurationFile $xca.Path -XPath $xca.XPath } default { throw "Unknown XML configuration action $($xca.Action)." } } } } # SIG # Begin signature block # MIIJEgYJKoZIhvcNAQcCoIIJAzCCCP8CAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB # gjcCAQSgWzBZMDQGCisGAQQBgjcCAR4wJgIDAQAABBAfzDtgWUsITrck0sYpfvNR # AgEAAgEAAgEAAgEAAgEAMCEwCQYFKw4DAhoFAAQUKH6WukFJri15xs4zOfetD7WT # eKugggWhMIIFnTCCA1GgAwIBAgIQKBOAjgMDO55A7UJ/k/g5nTBBBgkqhkiG9w0B # AQowNKAPMA0GCWCGSAFlAwQCAQUAoRwwGgYJKoZIhvcNAQEIMA0GCWCGSAFlAwQC # AQUAogMCASAwJjEkMCIGA1UEAwwbaWNyYWZ0c29mdHdhcmVAc3RhdGVsZXNzLmJl # MB4XDTIwMDYyMzExNDM1NloXDTIxMDYyMzEyMDM1NlowJjEkMCIGA1UEAwwbaWNy # YWZ0c29mdHdhcmVAc3RhdGVsZXNzLmJlMIICIjANBgkqhkiG9w0BAQEFAAOCAg8A # MIICCgKCAgEAmQcb0GwlBHBHBJZ9vNM8EewN7T+nhsWVU0WBoWnIw6UAT99Rw9x5 # RcfOQU2hxqKmR1k+iI6B+qddpTC3VLSChA/mh1P4p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+nILOUKJz8nmfujzTSdXiCnzidX70pvAn3woZLNxCE3xStpsjqi # 8khYlQs39I39oHWPZurzb3abDj0mamgs7WKk2cJ8RAjcSGcqzCJaysprehga5KWa # 2K/Ssu6b0kbe4QGwym1IIb/daRpJPiiMORPOUksxkYrXU6Y4KATCAxArDxpbpf8f # r9A7+gEFpFLM8TFhsDIcY1f0bsaufWz6Vrq3qOzWFhpwsOWtl78gMYT7zmaCtsIN # hjsE7VFVg65/kICPuhari1meo39oHpV76R6avul14BJ0gjkMlRLuXrFdsWM3xH69 # bNtW0VYczWXZ77n3jpKNjvWtPcn2RmAb6XnaQlXG+ffsq+Egm1yyZ8zTJ8ru1hzO # lViyOtm7kSzMVINbK29laUJcTWLIsw== # SIG # End signature block |