This repository has been archived by the owner on Mar 11, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPublish-DeploymentFolder.ps1
96 lines (83 loc) · 3.94 KB
/
Publish-DeploymentFolder.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# -----------------------------------------
#.SYNOPSIS
# Deployment folder creation for Dynamite components module.
#
# .DESCRIPTION
# 1) Create an empty deployment artifacts folder
# 2) Take the contents of NuGet package folder for GSoft.Dynamite.Models.CrossSitePublishingCMS
# and copy it all to that destination
# 3) Take the contents of current folder and copy it all to the destination
# 4) Take all WSP solution packages present in /Source/*/bin/ folders
# 5) Take all WSP solutions present in /../Libraries folders
#
#.PARAMETER Force
# Forces the deletion of the current Deployment folder and all it's contents (and the folder itself)
#
#.PARAMETER Release
# Fetches the solution packages (wsp) from the release folder
#
#.PARAMETER SetLocationToDestination
# Sets the current directory to the destination deployment folder after it's been created
# -----------------------------------------
Param (
[Parameter(Mandatory=$false)]
[switch]$Force,
[Parameter(Mandatory=$false)]
[switch]$Release,
[Parameter(Mandatory=$false)]
[switch]$SetLocationToDestination
)
# Build paths
$CurrentPath = Split-Path -Parent $MyInvocation.MyCommand.Path
$ProjectRootPath = Join-Path $CurrentPath "..\..\" | Resolve-Path
$DestinationPath = Join-Path $ProjectRootPath "Deployment"
$DefaultDefinitionsPath = Join-Path $ProjectRootPath "*\GSoft.Dynamite.StandardPublishingCMS*\tools" | Resolve-Path | Select-Object -last 1
$CustomDefinitionsPath = $CurrentPath | Resolve-Path
# Force delete all contents of current Deployment folder (and delete the folder itself)
if ($Force -eq $true)
{
if (Test-Path $DestinationPath) {
Write-Warning "Clearing the following path : $DestinationPath... "
Get-ChildItem -Path $DestinationPath -Recurse | Remove-Item -force -recurse
if (Test-Path -Path $DestinationPath) {
Remove-Item $DestinationPath
}
}
}
if (-not (Test-Path $DestinationPath))
{
# Create deployment folder
New-Item -ItemType Directory -Force -Path $DestinationPath | Out-Null
Write-Verbose "Created deployment folder at following path : $DestinationPath... "
# Start by copying the "vanilla" cross-site CMS setup scripts from the NuGet package
# Note: Exclude the NuGet's install script
Write-Verbose "Copying reference setup scripts and configuration from NuGet package (source: $DefaultDefinitionsPath)... "
Copy-DSPFiles $DefaultDefinitionsPath $DestinationPath -Match @("*.ps1","*.template.*","*.xlsx","*.jpg","*.jpeg","*.png","*.sgt", "README*", "*.psd1", "*.psm1") -Exclude "Install.ps1"
# Copy most contents of current "Scripts" folder to Deployment folder (powershell scripts, .template files, folder structure, etc.)
Write-Verbose "Copying custom scripts and configuration from current folder (source: $CustomDefinitionsPath)... "
Copy-DSPFiles $CustomDefinitionsPath $DestinationPath -Match @("*.ps1","*.template.*", "*.xlsx","*.jpg","*.jpeg","*.png","*.sgt", "README*","*.dll") -Exclude "Publish-DeploymentFolder.ps1"
# Copy all WSP files
$WspDestinationPath = Join-Path $DestinationPath "Solutions"
$LibrariesWspFilter = "*`\Libraries`\*"
$BinWspFilter = "*`\bin`\Debug"
if ($Release -eq $true)
{
$BinWspFilter = "*`\bin`\Release"
}
Copy-DSPSolutions $ProjectRootPath $WspDestinationPath $LibrariesWspFilter
Copy-DSPSolutions $ProjectRootPath $WspDestinationPath $BinWspFilter
# Copy DSP PowerShell module so it can be installed on destination server
$DSPModuleSourcePath = Join-Path $ProjectRootPath "Libraries\GSoft.Dynamite.SP*\tools\" | Resolve-Path | Select-Object -last 1
$DSPDestinationPath = Join-Path $DestinationPath "DSP"
Copy-DSPFiles $DSPModuleSourcePath $DSPDestinationPath
# Change directory into the Deployment folder if that's what the user asked for
if ($SetLocationToDestination -eq $true)
{
Set-Location $DestinationPath
}
}
else
{
Write-Warning "Skipped preparation of deployment contents because $DestinationPath already exists!!!"
Write-Verbose "Use -Force parameter to clear the folder automatically."
}