This repository has been archived by the owner on Jan 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 662
/
PostBuild.ps1
143 lines (137 loc) · 4.99 KB
/
PostBuild.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
param($ProjectDir, $ConfigurationName, $TargetDir, $TargetFileName, $SolutionDir)
if($ConfigurationName -like "Debug*")
{
$documentsFolder = [environment]::getfolderpath("mydocuments");
if($TargetDir -like "*Core*")
{
$DestinationFolder = "$documentsFolder\PowerShell\Modules\PnPPowerShellCore"
} else {
if($ConfigurationName -like "Debug15")
{
$DestinationFolder = "$documentsFolder\WindowsPowerShell\Modules\SharePointPnPPowerShell2013"
} elseif($ConfigurationName -like "Debug16")
{
$DestinationFolder = "$documentsFolder\WindowsPowerShell\Modules\SharePointPnPPowerShell2016"
} elseif($ConfigurationName -like "Debug19")
{
$DestinationFolder = "$documentsFolder\WindowsPowerShell\Modules\SharePointPnPPowerShell2019"
} else {
$DestinationFolder = "$documentsFolder\WindowsPowerShell\Modules\SharePointPnPPowerShellOnline"
}
}
# Module folder there?
if(Test-Path $DestinationFolder)
{
# Yes, empty it
Remove-Item $DestinationFolder\*
} else {
# No, create it
Write-Host "Creating target folder: $DestinationFolder"
New-Item -Path $DestinationFolder -ItemType Directory -Force >$null # Suppress output
}
Write-Host "Copying files from $TargetDir to $DestinationFolder"
Try {
Copy-Item "$TargetDir\*.dll" -Destination "$DestinationFolder"
Copy-Item "$TargetDir\*help.xml" -Destination "$DestinationFolder"
if($TargetDir -like "*Core*")
{
Copy-Item "$TargetDir\ModuleFiles\*" -Destination "$DestinationFolder"
} else {
switch($ConfigurationName)
{
"Debug15" {
Copy-Item "$TargetDir\ModuleFiles\SharePointPnPPowerShell2013.psd1" -Destination "$DestinationFolder"
Copy-Item "$TargetDir\ModuleFiles\PnP.PowerShell.2013.Commands.Format.ps1xml" -Destination "$DestinationFolder"
}
"Debug16" {
Copy-Item "$TargetDir\ModuleFiles\SharePointPnPPowerShell2016.psd1" -Destination "$DestinationFolder"
Copy-Item "$TargetDir\ModuleFiles\PnP.PowerShell.2016.Commands.Format.ps1xml" -Destination "$DestinationFolder"
}
"Debug19" {
Copy-Item "$TargetDir\ModuleFiles\SharePointPnPPowerShell2019.psd1" -Destination "$DestinationFolder"
Copy-Item "$TargetDir\ModuleFiles\PnP.PowerShell.2019.Commands.Format.ps1xml" -Destination "$DestinationFolder"
}
"Debug" {
Copy-Item "$TargetDir\ModuleFiles\SharePointPnPPowerShellOnline.psd1" -Destination "$DestinationFolder"
Copy-Item "$TargetDir\ModuleFiles\PnP.PowerShell.Online.Commands.Format.ps1xml" -Destination "$DestinationFolder"
}
}
}
}
Catch
{
exit 1
}
} elseif ($ConfigurationName -like "Release*")
{
$documentsFolder = [environment]::getfolderpath("mydocuments");
if($TargetDir -like "*Core*")
{
$DestinationFolder = "$documentsFolder\PowerShell\Modules\PnPPowerShellCore"
} else {
switch($ConfigurationName)
{
"Release15"
{
$DestinationFolder = "$documentsFolder\WindowsPowerShell\Modules\SharePointPnPPowerShell2013"
}
"Release16"
{
$DestinationFolder = "$documentsFolder\WindowsPowerShell\Modules\SharePointPnPPowerShell2016"
}
"Release19"
{
$DestinationFolder = "$documentsFolder\WindowsPowerShell\Modules\SharePointPnPPowerShell2019"
}
"Release"
{
$DestinationFolder = "$documentsFolder\WindowsPowerShell\Modules\SharePointPnPPowerShellOnline"
}
}
}
# Module folder there?
if(Test-Path $DestinationFolder)
{
# Yes, empty it
Remove-Item $DestinationFolder\*
} else {
# No, create it
Write-Host "Creating target folder: $DestinationFolder"
New-Item -Path $DestinationFolder -ItemType Directory -Force >$null # Suppress output
}
Write-Host "Copying files from $TargetDir to $DestinationFolder"
Try
{
Copy-Item "$TargetDir\*.dll" -Destination "$DestinationFolder"
Copy-Item "$TargetDir\*help.xml" -Destination "$DestinationFolder"
if($TargetDir -like "*Core*")
{
Copy-Item "$TargetDir\ModuleFiles\PnPPowerShellCore.psd1" -Destination "$DestinationFolder"
Copy-Item "$TargetDir\ModuleFiles\PnP.PowerShell.Core.Format.ps1xml" -Destination "$DestinationFolder"
} else {
switch($ConfigurationName)
{
"Release15" {
Copy-Item "$TargetDir\ModuleFiles\PnPPowerShell2013.psd1" -Destination "$DestinationFolder"
Copy-Item "$TargetDir\ModuleFiles\PnP.PowerShell.2013.Commands.Format.ps1xml" -Destination "$DestinationFolder"
}
"Release16" {
Copy-Item "$TargetDir\ModuleFiles\PnPPowerShell2016.psd1" -Destination "$DestinationFolder"
Copy-Item "$TargetDir\ModuleFiles\PnP.PowerShell.2016.Commands.Format.ps1xml" -Destination "$DestinationFolder"
}
"Release19" {
Copy-Item "$TargetDir\ModuleFiles\PnPPowerShell2019.psd1" -Destination "$DestinationFolder"
Copy-Item "$TargetDir\ModuleFiles\PnP.PowerShell.2019.Commands.Format.ps1xml" -Destination "$DestinationFolder"
}
"Release" {
Copy-Item "$TargetDir\ModuleFiles\PnPPowerShellOnline.psd1" -Destination "$DestinationFolder"
Copy-Item "$TargetDir\ModuleFiles\PnP.PowerShell.Online.Commands.Format.ps1xml" -Destination "$DestinationFolder"
}
}
}
}
Catch
{
exit 1
}
}