Skip to content

Commit

Permalink
(GH-13) Uninstall script
Browse files Browse the repository at this point in the history
Remove the existing site files minus App_Data and web.config.
  • Loading branch information
ferventcoder committed Jan 4, 2018
1 parent 1d9742f commit de45c97
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions nuget/tools/chocolateyuninstall.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
$packageName = $env:ChocolateyPackageName
$webInstallDir = Join-Path (Get-ToolsLocation) $packageName

if (Test-Path $webInstallDir) {
try {
Write-Debug "Removing all but the App_Data folder in the existing '$webInstallDir'"
Get-ChildItem -Path "$webInstallDir" -Recurse | % {
if ($_.FullName -match 'App_Data' -or $_.FullName -match 'Web.config') {
Write-Debug " - Skipping $($_.FullName)"
} else {
Write-Debug " - Removing $($_.FullName)"
Remove-Item $_.FullName -Recurse -Force -ErrorAction SilentlyContinue
}
}
}
catch {
Write-Warning "Had an error deleting files from '$webInstallDir'. You will need to manually remove files. Error: $_"
}

Write-Warning "Removed all from '$webInstallDir' except for App_Data. You should inspect and remove packages/logs manually."
}

0 comments on commit de45c97

Please sign in to comment.