forked from Tachyonite/Pawnmorpher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.ps1
89 lines (64 loc) · 2.49 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
param (
$buildName ="Pawnmorpher",
$buildDir = "Build" ,
$VSVersion = "2019",
$OutVersion = "",
$buildType = "Debug"
)
If (!(test-path $buildDir)) {
New-Item -ItemType Directory -Force -Path $buildDir
}
If (!(test-path "$buildDir/Tmp")) {
New-Item -ItemType Directory -Force -Path "$buildDir\Tmp"
}
else {
Remove-Item -Recurse -Force "$buildDir\Tmp"
New-Item -ItemType Directory -Force -Path "$buildDir\Tmp"
#clean contents of temp directory
}
If (Test-Path "$buildDir/$buildName$OutVersion.zip") {
Remove-Item -Path "$buildDir/$buildName$OutVersion.zip" -Force
}
dotnet restore "Source/Pawnmorphs/Pawnmorph.sln"
if (!$?) {
Write-Error "could not restore project"
exit 1
}
."C:\Program Files (x86)\Microsoft Visual Studio\$VSVersion\Community\MSBuild\Current\Bin\MSBuild.exe" "Source/Pawnmorphs/Pawnmorph.sln" /t:restore
if (!$?) {
Write-Error "could not restore project"
exit 1
}
."C:\Program Files (x86)\Microsoft Visual Studio\$VSVersion\Community\MSBuild\Current\Bin\MSBuild.exe" "Source/Pawnmorphs/Pawnmorph.sln" /t:Rebuild /p:Configuration=$buildType /p:Platform="any cpu"
if (!$?) {
Write-Error "could not build project"
exit 1
}
Copy-Item -Path Defs, About, "1.3", "1.2", "1.1", "1.0" , Languages, Patches, Textures -Destination "$buildDir/Tmp" -Recurse
Copy-Item -Path LoadFolders.xml -Destination "$buildDir/Tmp/LoadFolders.xml"
#Remove hugs lib dll if present
if (Test-Path "$buildDir/Tmp/1.1/Assemblies/HugsLib.dll") {
Remove-Item "$buildDir/Tmp/1.1/Assemblies/HugsLib.dll"
}
#Remove hugs lib dll if present
if (Test-Path "$buildDir/Tmp/1.3/Assemblies/HugsLib.dll") {
Remove-Item "$buildDir/Tmp/1.3/Assemblies/HugsLib.dll"
}
#check for .vs folders and get rid of them
if (Test-Path "$buildDir/Tmp/.vs") {
Remove-Item "$buildDir/Tmp/.vs" -Recurse -Force
}
if (Test-Path "$buildDir/Tmp/Source/Pawnmorphs/.vs") {
Remove-Item "$buildDir/Tmp/Source/Pawnmorphs/.vs" -Recurse -Force
}
#get rid of nuget packages
if (Test-Path "$buildDir/Tmp/Source/Pawnmorphs/packages") {
Remove-Item "$buildDir/Tmp/Source/Pawnmorphs/packages" -Force -Recurse
}
Compress-Archive -Path "$buildDir/Tmp/*" -CompressionLevel Optimal -Force -DestinationPath "$buildDir/$buildName-$buildType $(get-date -f MM-dd).zip"
if (!$?) {
Write-Error "unable to create archive"
exit 1
}
Remove-Item -Path "$buildDir/Tmp" -Recurse -Force
Write-Output "file $buildDir/$buildName-$buildType $(get-date -f MM-dd).zip created successfully"