forked from FOGProject/fog-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.ps1
174 lines (147 loc) · 8.02 KB
/
build.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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
param(
[switch]$sign,
[switch]$publish,
[string]$server = $(if ($publish) { Read-Host "Input server address"} ),
[string]$path = $(if ($publish) { Read-Host "Input remote path"} ),
[string]$user = $(if ($publish) { Read-Host "Input user name"} ),
[string]$channel = $(if ($publish) { Read-Host "Input channel(nightly, release-candidate, release)"} ),
[string]$name = $(if ($publish) { Read-Host "Input build name"} ),
[string]$ilMerge = "ilmerge.exe",
[string]$msbuild = "msbuild.exe",
[string]$nuget = "$PSScriptRoot\.nuget\NuGet.exe",
[string]$plink = "$PSScriptRoot\BuildTools\plink.exe",
[string]$pscp = "$PSScriptRoot\BuildTools\pscp.exe",
[string]$signer = "$PSScriptRoot\BuildTools\SignCode.cmd",
[string]$sshKey = "$PSScriptRoot\BuildTools\auth.ppk",
[string]$netPath = "C:\Windows\Microsoft.NET\Framework64\v4.0.30319"
)
##################################################
# External API
##################################################
Add-Type -Assemblyname System.IO.Compression.FileSystem
function Zip
{
param([string]$inPath, [string]$zipPath)
[System.IO.Compression.ZipFile]::CreateFromDirectory($inPath, $zipPath) | out-null
}
##################################################
# VARIABLE SETUP
##################################################
$nuget = ($nuget + " ")
$ilMerge = ($ilMerge + " ")
$msbuild = ($msbuild + " ")
$plink = ($plink + " ")
$pscp = ($pscp + " ")
$buildMode = "/verbosity:minimal /p:configuration=Release"
$solutionConfig = "$PSScriptRoot\FOGService.sln $buildMode"
$installerConfig = "$PSScriptRoot\UniversalInstaller\UniversalInstaller.csproj $buildMode"
$msiConfig = "$PSScriptRoot\MSI\MSI.wixproj $buildMode"
$trayConfig = "$PSScriptRoot\Tray\Tray.csproj"
$toSign = "Zazzles.dll", "Modules.dll", "FOGService.exe", "FOGShutdownGUI.exe", "FOGUpdateHelper.exe", "FOGUpdateWaiter.exe", "FOGUserService.exe", "FOGTray.exe"
$signExec = "cmd.exe /c ""$signer"" ""$PSScriptRoot\"
$plinkConfig = "-i ""$sshKey"" $user@$server mkdir $path" + "$channel" + "/" + "$name"
$pscpConfig = "-i ""$sshKey"" -r $PSScriptRoot\out\* $user" + "@" + "$server" + ":" + "$path$channel" + "/" + "$name"
$printerMerge = "/ndebug /copyattrs /targetplatform:4.0``,""$netPath"" /out:""$PSScriptRoot\out\PrinterManagerHelper.exe"" ""$PSScriptRoot\bin\PrinterManagerHelper.exe"" ""$PSScriptRoot\bin\Zazzles.dll"" ""$PSScriptRoot\bin\Newtonsoft.Json.dll"" ""$PSScriptRoot\bin\Modules.dll"""
$smartInstallerMerge = "/ndebug /copyattrs /targetplatform:4.0``,""$netPath"" /out:""$PSScriptRoot\out\SmartInstaller.exe"" ""$PSScriptRoot\bin\SmartInstaller.exe"" ""$PSScriptRoot\bin\Zazzles.dll"" ""$PSScriptRoot\bin\Newtonsoft.Json.dll"" ""$PSScriptRoot\bin\ICSharpCode.SharpZipLib.dll"" ""$PSScriptRoot\bin\SetupHelper.dll"""
$debuggerMerge = "/ndebug /copyattrs /targetplatform:4.0``,""$netPath"" /out:""$PSScriptRoot\out\Debugger.exe"" " + `
"""$PSScriptRoot\bin\Debugger.exe"" ""$PSScriptRoot\bin\Zazzles.dll"" " + `
"""$PSScriptRoot\bin\Newtonsoft.Json.dll"" ""$PSScriptRoot\bin\SetupHelper.dll"" " + `
"""$PSScriptRoot\bin\Modules.dll"" ""$PSScriptRoot\bin\EngineIoClientDotNet.dll"" " + `
"""$PSScriptRoot\bin\log4net.dll"" ""$PSScriptRoot\bin\ProcessPrivileges.dll"" " + `
"""$PSScriptRoot\bin\SuperSocket.Common.dll"" ""$PSScriptRoot\bin\Quartz.dll"" " + `
"""$PSScriptRoot\bin\Common.Logging.Core.dll"" ""$PSScriptRoot\bin\Common.Logging.dll"""
$toZip = "EngineIoClientDotNet.dll", "FOGService.exe", "FOGService.exe.config", "FOGShutdownGUI.exe", `
"FOGShutdownGUI.exe.config", "FOGTray.exe", "FOGTray.exe.config", "FOGUpdateHelper.exe", `
"FOGUpdateHelper.exe.config", "FOGUpdateWaiter.exe", "FOGUpdateWaiter.exe.config", `
"FOGUserService.exe", "FOGUserService.exe.config", "log4net.dll", "logo.ico", `
"MetroFramework.dll", "MetroFramework.Fonts.dll", `
"Modules.dll", "Modules.dll.config", "Newtonsoft.Json.dll", "ProcessPrivileges.dll", `
"SuperSocket.ClientEngine.dll", "SuperSocket.Common.dll", "SuperSocket.SocketBase.dll", `
"SuperSocket.SocketEngine.dll", "SuperWebSocket.dll", "themes.xml", `
"WebSocket4Net.dll", "Zazzles.dll", "Quartz.dll", "Common.Logging.dll", `
"Common.Logging.Core.dll", "ICSharpCode.SharpZipLib.dll", "de", "fr", "nl", "no", "eu", "es", "hu", "pt", "cs", "ro", "pl", "it"
##################################################
# Initial Build
##################################################
Write-Host "Restoring Packages"
Invoke-Expression ($nuget + "restore") | out-null
Write-Host "Cleaning Projects"
Invoke-Expression ($msbuild + $solutionConfig + " /t:Clean")
Invoke-Expression ($msbuild + $installerConfig + " /t:Clean")
Invoke-Expression ($msbuild + $msiConfig + " /t:Clean")
If (Test-Path "$PSScriptRoot\bin"){ Remove-Item -Recurse "$PSScriptRoot\bin" | out-null }
If (Test-Path "$PSScriptRoot\bin"){ Remove-Item -Recurse "$PSScriptRoot\bin" | out-null }
If (Test-Path "$PSScriptRoot\bin"){ Remove-Item -Recurse "$PSScriptRoot\bin" | out-null }
New-Item -ItemType directory -Path "$PSScriptRoot\bin" | out-null
Write-Host "Building Solution"
Invoke-Expression ($msbuild + $solutionConfig) | out-null
Write-Host "Copying Theme to build"
Copy-Item "$PSScriptRoot\themes.xml" "$PSScriptRoot\bin\themes.xml"
##################################################
# Build Installers
##################################################
if ($sign) {
Write-Host "Signing Binaries"
foreach ($file in $toSign) {
Write-Host "--> $file"
Invoke-Expression($signExec + "bin\$file""") | out-null
}
}
Write-Host "Zipping Build for installer"
$InstallerZip = "$PSScriptRoot\UniversalInstaller\Scripts\FOGService.zip"
if (Test-Path $InstallerZip) { Remove-Item $InstallerZip | out-null }
If (Test-Path "$PSScriptRoot\bin\tmp"){ Remove-Item -Recurse "$PSScriptRoot\bin\tmp" | out-null }
New-Item -ItemType directory -Path "$PSScriptRoot\bin\tmp" | out-null
foreach ($file in $toZip) {
Copy-Item ("$PSScriptRoot\bin\" + $file) ("$PSScriptRoot\bin\tmp\" + $file) -recurse | out-null
}
Zip "$PSScriptRoot\bin\tmp" $InstallerZip | out-null
If (Test-Path "$PSScriptRoot\out"){ Remove-Item -Recurse "$PSScriptRoot\out" | out-null }
If (Test-Path "$PSScriptRoot\out"){ Remove-Item -Recurse "$PSScriptRoot\out" | out-null }
If (Test-Path "$PSScriptRoot\out"){ Remove-Item -Recurse "$PSScriptRoot\out" | out-null }
New-Item -ItemType directory -Path "$PSScriptRoot\out" | out-null
Write-Host "Building MSI"
Invoke-Expression ($msbuild + $msiConfig) | out-null
$InstallerMSI = "$PSScriptRoot\UniversalInstaller\Scripts\FOGService.msi"
if ($sign) {
Write-Host "Signing MSI"
Invoke-Expression($signExec + "bin\FOGService.msi""") | out-null
}
if (Test-Path $InstallerMSI) { Remove-Item $InstallerMSI }
Copy-Item "$PSScriptRoot\bin\FOGService.msi" $InstallerMSI
Copy-Item "$PSScriptRoot\bin\FOGService.msi" "$PSScriptRoot\out\FOGService.msi"
Write-Host "Building Smart Installer"
Invoke-Expression ($msbuild + $installerConfig) | out-null
Write-Host "ILMerging Smart Installer"
Invoke-Expression ($ilMerge + $smartInstallerMerge )
if ($sign) {
Write-Host "Signing Smart Installer"
Invoke-Expression($signExec + "out\SmartInstaller.exe""") | out-null
}
##################################################
# Build Debugger
##################################################
Write-Host "ILMerging Debugger"
Invoke-Expression ($ilMerge + $debuggerMerge)
if ($sign) {
Write-Host "Signing Debugger"
Invoke-Expression($signExec + "out\Debugger.exe""") | out-null
}
##################################################
# Build PrinterManager Helper
##################################################
Write-Host "ILMerging PrinterManagerHelper"
Invoke-Expression ($ilMerge + $printerMerge)
if ($sign) {
Write-Host "Signing PrinterManager Helper"
Invoke-Expression($signExec + "out\PrinterManagerHelper.exe""") | out-null
}
##################################################
# Publish Build
##################################################
if ($publish) {
Write-Host "Making remote folder"
Invoke-Expression ($plink + $plinkConfig)
Write-Host "Sending build to server"
Invoke-Expression ($pscp + $pscpConfig)
}