-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdeploy.ps1
More file actions
68 lines (51 loc) · 3.35 KB
/
deploy.ps1
File metadata and controls
68 lines (51 loc) · 3.35 KB
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
######################################################################################################
# More info here: https://msdn.microsoft.com/en-us/library/xc3tc5xx.aspx
# This answer in SO can be usefull too: https://stackoverflow.com/a/8192093/2576706
#
######################################################################################################
###### Variables ######
$Version = "20.0.0.0"
$AppName = "SoftFluentApp4" # do not call the Unity project the same as $AppName in deploy script
$Publisher = "SoftFluent"
$ServerUrl = "\\sfsrv03\Temp\lfe\Deployment"
# Directory
$BinDirectory = "Bin" # Unity compiled application (everything in this folder will be compressed!)
$OutputDirectory = "Output" # Output (manifests and compressed archive)
$ToolsDirectory = "Tools" # Launcher.exe (a simple console application that launch the Unity Project and unzip it if necessary)
# Other
$IconFile = "icon.ico"
########################################################################
# 1) Prepare the application in the Output folder
# Clear Output directory (create if doesn't exists)
New-Item -ItemType Directory -Force -Path $OutputDirectory
Remove-Item $OutputDirectory\* -recurse
# Compress the Unity application from the bin directory and put it in the Output directory
Add-Type -Assembly System.IO.Compression.FileSystem
$compressionLevel = [System.IO.Compression.CompressionLevel]::Optimal
[System.IO.Compression.ZipFile]::CreateFromDirectory($BinDirectory, "$OutputDirectory\App.zip", $compressionLevel, $false)
# Then add the icon and the Launcher.exe in Output directory (and rename it to the name of the project)
Copy-Item -Path $IconFile $OutputDirectory
Copy-Item -Path $ToolsDirectory\Launcher.exe $OutputDirectory
Rename-Item $OutputDirectory\Launcher.exe "$AppName.exe"
# Set a file with some informations in it
$file = "$OutputDirectory\infos.txt"
"Version:$Version" | Set-Content $file
"AppName:$AppName" | Add-Content $file
"Publisher:$Publisher" | Add-Content $file
"ServerUrl:$ServerUrl" | Add-Content $file
"IconFile:$IconFile" | Add-Content $file
########################################################################
# 2) Manifest Creation
.\mage -New Application -name "$AppName" -Version $Version -IconFile $IconFile -FromDirectory $OutputDirectory\ -ToFile "$OutputDirectory\$AppName.exe.manifest"
# TODO: sign the manifest with Authenticode certificate (Replace mycert.pfx with the path to your certificate file. Replace passwd with the password for your certificate file.)
#mage -Sign $AppName.exe.manifest -CertFile mycert.pfx -Password passwd
########################################################################
# 3) Installer Generation
.\mage -New Deployment -name "$AppName" -Version $Version -Install true -Publisher $Publisher -ProviderUrl "$ServerUrl\$AppName.application" -AppManifest "$OutputDirectory\$AppName.exe.manifest" -ToFile "$OutputDirectory\$AppName.application"
# TODO: Sign the deployment manifest
# mage -Sign $AppName.application -CertFile mycert.pfx -Password passwd
########################################################################
# 4) Deployment
# Copy all of the files in the deployment directory to the deployment destination or media.
Remove-Item $ServerUrl\* -recurse
Copy-Item -Path $OutputDirectory\* -Destination $ServerUrl\ -Container;