forked from pnp/PnP-PowerShell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PostBuild.ps1
132 lines (125 loc) · 4.94 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
param($ProjectDir, $ConfigurationName, $TargetDir, $TargetFileName, $SolutionDir)
if($ConfigurationName -like "Debug*")
{
$documentsFolder = [environment]::getfolderpath("mydocuments");
if($ConfigurationName -like "Debug15")
{
$DestinationFolder = "$documentsFolder\WindowsPowerShell\Modules\SharePointPnPPowerShell2013"
} elseif($ConfigurationName -like "Debug16")
{
$DestinationFolder = "$documentsFolder\WindowsPowerShell\Modules\SharePointPnPPowerShell2016"
} 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"
switch($ConfigurationName)
{
"Debug15" {
Copy-Item "$TargetDir\ModuleFiles\SharePointPnPPowerShell2013.psd1" -Destination "$DestinationFolder"
Copy-Item "$TargetDir\ModuleFiles\SharePointPnP.PowerShell.2013.Commands.Format.ps1xml" -Destination "$DestinationFolder"
if(Test-Path -Path "$TargetDir\ModuleFiles\SharePointPnPPowerShell2013Aliases.psm1")
{
Copy-Item "$TargetDir\ModuleFiles\SharePointPnPPowerShell2013Aliases.psm1" -Destination "$DestinationFolder"
}
}
"Debug16" {
Copy-Item "$TargetDir\ModuleFiles\SharePointPnPPowerShell2016.psd1" -Destination "$DestinationFolder"
Copy-Item "$TargetDir\ModuleFiles\SharePointPnP.PowerShell.2016.Commands.Format.ps1xml" -Destination "$DestinationFolder"
if(Test-Path -Path "$TargetDir\ModuleFiles\SharePointPnPPowerShell2016Aliases.psm1")
{
Copy-Item "$TargetDir\ModuleFiles\SharePointPnPPowerShell2016Aliases.psm1" -Destination "$DestinationFolder"
}
}
"Debug" {
Copy-Item "$TargetDir\ModuleFiles\SharePointPnPPowerShellOnline.psd1" -Destination "$DestinationFolder"
Copy-Item "$TargetDir\ModuleFiles\SharePointPnP.PowerShell.Online.Commands.Format.ps1xml" -Destination "$DestinationFolder"
if(Test-Path -Path "$TargetDir\ModuleFiles\SharePointPnPPowerShellOnlineAliases.psm1")
{
Copy-Item "$TargetDir\ModuleFiles\SharePointPnPPowerShellOnlineAliases.psm1" -Destination "$DestinationFolder"
}
}
}
}
Catch
{
exit 1
}
} elseif ($ConfigurationName -like "Release*")
{
$documentsFolder = [environment]::getfolderpath("mydocuments");
switch($ConfigurationName)
{
"Release15"
{
$DestinationFolder = "$documentsFolder\WindowsPowerShell\Modules\SharePointPnPPowerShell2013"
}
"Release16"
{
$DestinationFolder = "$documentsFolder\WindowsPowerShell\Modules\SharePointPnPPowerShell2016"
}
"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"
switch($ConfigurationName)
{
"Release15" {
Copy-Item "$TargetDir\ModuleFiles\SharePointPnPPowerShell2013.psd1" -Destination "$DestinationFolder"
Copy-Item "$TargetDir\ModuleFiles\SharePointPnP.PowerShell.2013.Commands.Format.ps1xml" -Destination "$DestinationFolder"
if(Test-Path -Path "$TargetDir\ModuleFiles\SharePointPnPPowerShell2013Aliases.psm1")
{
Copy-Item "$TargetDir\ModuleFiles\SharePointPnPPowerShell2013Aliases.psm1" -Destination "$DestinationFolder"
}
}
"Release16" {
Copy-Item "$TargetDir\ModuleFiles\SharePointPnPPowerShell2016.psd1" -Destination "$DestinationFolder"
Copy-Item "$TargetDir\ModuleFiles\SharePointPnP.PowerShell.2016.Commands.Format.ps1xml" -Destination "$DestinationFolder"
if(Test-Path -Path "$TargetDir\ModuleFiles\SharePointPnPPowerShell2016Aliases.psm1")
{
Copy-Item "$TargetDir\ModuleFiles\SharePointPnPPowerShell2016Aliases.psm1" -Destination "$DestinationFolder"
}
}
"Release" {
Copy-Item "$TargetDir\ModuleFiles\SharePointPnPPowerShellOnline.psd1" -Destination "$DestinationFolder"
Copy-Item "$TargetDir\ModuleFiles\SharePointPnP.PowerShell.Online.Commands.Format.ps1xml" -Destination "$DestinationFolder"
if(Test-Path -Path "$TargetDir\ModuleFiles\SharePointPnPPowerShellOnlineAliases.psm1")
{
Copy-Item "$TargetDir\ModuleFiles\SharePointPnPPowerShellOnlineAliases.psm1" -Destination "$DestinationFolder"
}
}
}
}
Catch
{
exit 1
}
}