92 lines
3.3 KiB
PowerShell
92 lines
3.3 KiB
PowerShell
param($rootPath, $toolsPath, $package, $project)
|
|
|
|
if ($project) {
|
|
$dateTime = Get-Date -Format yyyyMMdd-HHmmss
|
|
$backupPath = Join-Path (Split-Path $project.FullName -Parent) "\App_Data\NuGetBackup\$dateTime"
|
|
$copyLogsPath = Join-Path $backupPath "CopyLogs"
|
|
$projectDestinationPath = Split-Path $project.FullName -Parent
|
|
|
|
# Create backup folder and logs folder if it doesn't exist yet
|
|
New-Item -ItemType Directory -Force -Path $backupPath
|
|
New-Item -ItemType Directory -Force -Path $copyLogsPath
|
|
|
|
# Create a backup of original web.config
|
|
$webConfigSource = Join-Path $projectDestinationPath "Web.config"
|
|
Copy-Item $webConfigSource $backupPath -Force
|
|
|
|
# Backup config files folder
|
|
$configFolder = Join-Path $projectDestinationPath "Config"
|
|
if(Test-Path $configFolder) {
|
|
$umbracoBackupPath = Join-Path $backupPath "Config"
|
|
New-Item -ItemType Directory -Force -Path $umbracoBackupPath
|
|
|
|
robocopy $configFolder $umbracoBackupPath /e /LOG:$copyLogsPath\ConfigBackup.log
|
|
}
|
|
|
|
# Copy umbraco and umbraco_files from package to project folder
|
|
# This is only done when these folders already exist because we
|
|
# only want to do this for upgrades
|
|
$umbracoFolder = Join-Path $projectDestinationPath "Umbraco"
|
|
if(Test-Path $umbracoFolder) {
|
|
$umbracoFolderSource = Join-Path $rootPath "UmbracoFiles\Umbraco"
|
|
|
|
$umbracoBackupPath = Join-Path $backupPath "Umbraco"
|
|
New-Item -ItemType Directory -Force -Path $umbracoBackupPath
|
|
|
|
robocopy $umbracoFolder $umbracoBackupPath /e /LOG:$copyLogsPath\UmbracoBackup.log
|
|
robocopy $umbracoFolderSource $umbracoFolder /is /it /e /xf UI.xml /LOG:$copyLogsPath\UmbracoCopy.log
|
|
}
|
|
|
|
$umbracoClientFolder = Join-Path $projectDestinationPath "Umbraco_Client"
|
|
if(Test-Path $umbracoClientFolder) {
|
|
$umbracoClientFolderSource = Join-Path $rootPath "UmbracoFiles\Umbraco_Client"
|
|
|
|
$umbracoClientBackupPath = Join-Path $backupPath "Umbraco_Client"
|
|
New-Item -ItemType Directory -Force -Path $umbracoClientBackupPath
|
|
|
|
robocopy $umbracoClientFolder $umbracoClientBackupPath /e /LOG:$copyLogsPath\UmbracoClientBackup.log
|
|
robocopy $umbracoClientFolderSource $umbracoClientFolder /is /it /e /LOG:$copyLogsPath\UmbracoClientCopy.log
|
|
}
|
|
|
|
$copyWebconfig = $true
|
|
$destinationWebConfig = Join-Path $projectDestinationPath "Web.config"
|
|
|
|
if(Test-Path $destinationWebConfig)
|
|
{
|
|
Try
|
|
{
|
|
[xml]$config = Get-Content $destinationWebConfig
|
|
|
|
$config.configuration.appSettings.ChildNodes | ForEach-Object {
|
|
if($_.key -eq "umbracoConfigurationStatus")
|
|
{
|
|
# The web.config has an umbraco-specific appSetting in it
|
|
# don't overwrite it and let config transforms do their thing
|
|
$copyWebconfig = $false
|
|
}
|
|
}
|
|
}
|
|
Catch { }
|
|
}
|
|
|
|
if($copyWebconfig -eq $true)
|
|
{
|
|
$packageWebConfigSource = Join-Path $rootPath "UmbracoFiles\Web.config"
|
|
Copy-Item $packageWebConfigSource $destinationWebConfig -Force
|
|
}
|
|
|
|
$installFolder = Join-Path $projectDestinationPath "Install"
|
|
if(Test-Path $installFolder) {
|
|
Remove-Item $installFolder -Force -Recurse -Confirm:$false
|
|
}
|
|
|
|
# Open appropriate readme
|
|
if($copyWebconfig -eq $true)
|
|
{
|
|
$DTE.ItemOperations.OpenFile($toolsPath + '\Readme.txt')
|
|
}
|
|
else
|
|
{
|
|
$DTE.ItemOperations.OpenFile($toolsPath + '\ReadmeUpgrade.txt')
|
|
}
|
|
} |