Skip to content

Instantly share code, notes, and snippets.

Last active September 19, 2017 12:59
What would you like to do?
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…
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