Last active
January 24, 2021 02:07
-
-
Save MartinMiles/d699b960bb8a33e8ee529aa536ea39a6 to your computer and use it in GitHub Desktop.
his scripts uses SAT for converting a Sitecore Publishing Module into a WebDeploy package to deploy into Azure PaaS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Usage: | |
# .\ConvertTo-PublishingModuleWdp.ps1 -SitecoreAzureToolkitRoot "C:\Sitecore\SAT" -Path "C:\Sitecore Publishing Module 3.1.4 rev. 200110.zip" -Destination "C:\output" | |
[CmdletBinding()] | |
Param( | |
[Parameter(Mandatory=$true)] | |
[ValidateScript({ Test-Path $_ -PathType Container -IsValid })] | |
[string]$SitecoreAzureToolkitRoot, | |
[Parameter(Mandatory = $true)] | |
[ValidateScript({ (Test-Path $_ -PathType Leaf) -and ($_ -match '\.zip$') })] | |
[string]$Path, | |
[Parameter(Mandatory=$true)] | |
[ValidateScript({ Test-Path $_ -PathType Container -IsValid })] | |
[string]$Destination, | |
[switch]$GenerateCdPackage | |
) | |
Import-Module "$SitecoreAzureToolkitRoot\tools\Sitecore.Cloud.Cmdlets.dll" | |
Add-Type -Path "$SitecoreAzureToolkitRoot\tools\DotNetZip.dll" | |
$sourcePath = (Resolve-Path $Path).Path | |
if(!(Test-Path $Destination)) { | |
New-Item -ItemType Directory -Path $Destination | |
} | |
$destinationPath = (Resolve-Path $Destination).Path | |
$scWdpPath = ConvertTo-SCModuleWebDeployPackage ` | |
-Path "$sourcePath" ` | |
-Destination "$destinationPath" ` | |
-Verbose ` | |
-Force | |
try { | |
# Add Publishing Service URL parameter into WDP | |
$publishingServiceConfig = "Sitecore.Publishing.Service.config" | |
[xml]$publishingParameter = ` | |
"<parameter name=`"Publishing Service URL`" description=`"URL to the Publishing Service Site`" tags=`"Hidden,NoStore`">" + | |
"<parameterEntry kind=`"XmlFile`" scope=`"$([Regex]::Escape($publishingServiceConfig))`" match=`"/configuration/sitecore/settings/setting[@name='PublishingService.UrlRoot']/@value`" />" + | |
"</parameter>" | |
$zip = [Ionic.Zip.ZipFile]::new($scWdpPath) | |
$parametersFile = $zip.Entries | Where-Object { $_.FileName -eq "parameters.xml" } | |
($parametersXml = New-Object System.Xml.XmlDocument).Load($parametersFile.OpenReader()) | |
$parametersXml.parameters.AppendChild($parametersXml.ImportNode($publishingParameter.parameter, $true)) | Out-Null | |
$parametersStream = New-Object System.IO.MemoryStream | |
$parametersXml.Save($parametersStream) | |
$parametersStream.Seek(0, [System.IO.SeekOrigin]::Begin) | Out-Null | |
$zip.UpdateEntry($parametersFile.FileName, $parametersStream) | Out-Null | |
$zip.Save() | |
} finally { | |
if ($zip) { $zip.Dispose() } | |
if ($parametersStream) { $parametersStream.Dispose() } | |
} | |
if (!$GenerateCdPackage) { return } | |
Remove-SCDatabaseOperations -Path "$scWdpPath" -Destination "$destinationPath" -Verbose -Force |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment