Last active
September 19, 2017 12:59
-
-
Save jraps20/a629f1830c28116080822f94447f5bcd to your computer and use it in GitHub Desktop.
Remove \bin Files from a Sitecore Update package. This came about due to the fact that the TDS package generator adds `HedgehogDevelopment.SitecoreProject.PackageInstallPostProcessor.dll` even when you select not to include files with the package. By removing this file, the app pool does not recycle during installations. This requires that `Hedg…
This file contains 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
Param( | |
[string]$pathToPackages | |
) | |
Add-Type -AssemblyName System.IO.Compression.FileSystem | |
function Unzip | |
{ | |
param([string]$zipfile, [string]$outpath) | |
[System.IO.Compression.ZipFile]::ExtractToDirectory($zipfile, $outpath) | |
} | |
function ZipDirectory | |
{ | |
param([string]$zipfilename, [string]$sourcedir) | |
$compressionLevel = [System.IO.Compression.CompressionLevel]::Optimal | |
[System.IO.Compression.ZipFile]::CreateFromDirectory($sourcedir, $zipfilename, $compressionLevel, $false) | |
} | |
function RemoveBinFiles | |
{ | |
param([string]$path, [string]$updateFile) | |
$packageNameOnly = "$($path)\$($updateFile)" | |
$package = "$($packageNameOnly).update" | |
$packageDirectory = "$($path)\package" | |
$packageZip = "$($packageDirectory).zip" | |
$packageBin = "$($packageDirectory)\addedFiles\bin" | |
$packagePropertiesBin = "$($packageDirectory)\properties\addedFiles\bin" | |
Unzip $package $path | |
if (Test-Path $packageDirectory) { | |
Remove-Item $packageDirectory -recurse | |
} | |
Unzip $packageZip $packageDirectory | |
Remove-Item $packageZip | |
if (Test-Path $packageBin) { | |
Remove-Item $packageBin -recurse | |
} | |
if (Test-Path $packagePropertiesBin) { | |
Remove-Item $packagePropertiesBin -recurse | |
} | |
ZipDirectory $packageZip $packageDirectory | |
if (Test-Path $packageDirectory) { | |
Remove-Item $packageDirectory -recurse | |
} | |
if (Test-Path $package) { | |
Remove-Item $package | |
} | |
New-Item -ItemType directory -Path $packageNameOnly | |
Move-Item -Path $packageZip -Destination $packageNameOnly | |
ZipDirectory $package $packageNameOnly | |
if (Test-Path $packageNameOnly) { | |
Remove-Item $packageNameOnly -recurse | |
} | |
} | |
Get-ChildItem $pathToPackages -Filter *.update | | |
Foreach-Object { | |
$packageName = $_.BaseName | |
Write-Host $packageName | |
RemoveBinFiles $pathToPackages $packageName | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment