forked from HearthSim/Hearthstone-Deck-Tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PreBuild.ps1
74 lines (60 loc) · 1.79 KB
/
PreBuild.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
param(
[Parameter(Mandatory=$true)]
[string]$solution,
[Parameter(Mandatory=$true)]
[string]$project,
[Parameter(Mandatory=$true)]
[string]$target,
[switch]$skipGitSync = $false,
[switch]$skipResourceCopy = $false
)
"Solution: $solution"
"Project: $project"
"Target: $target"
"Skip git sync: $skipGitSync"
"Skip resource copy: $skipResourceCopy`n"
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
function CopyFiles($source, $files, $target) {
if((Test-Path $source) -and (Test-Path $target)) {
"`nCopying files from $source to $target"
Copy-Item -Force -Recurse "$source\$files" $target
}
}
function Create($path) {
if(-not (Test-Path $path)) {
"`nCreating directory: $path"
New-Item -ItemType "directory" -Path $path
}
}
function SyncRepo($name, $localDir, $branch = "origin/master") {
$localPath = "$solution$localDir"
if(Test-Path $localPath) {
"`nResetting $localDir to $branch"
git -C $localPath fetch
git -C $localPath reset --hard $branch
} else {
git clone --depth 1 "https://github.com/$name.git" $localPath
}
}
function FetchLib($name) {
"Fetching $name..."
$url = "https://libs.hearthsim.net/hdt/$name.dll"
(New-Object Net.WebClient).DownloadFile($url, "$solution\lib\$name.dll")
}
if(-not $skipGitSync) {
FetchLib "HearthDb"
FetchLib "HearthMirror"
FetchLib "HSReplay"
FetchLib "BobsBuddy"
SyncRepo "HearthSim/HDT-Localization" "HDT-Localization"
}
if(-not $skipResourceCopy) {
CopyFiles "$($solution)HDT-Localization" "*.resx" "$($project)Properties\"
$images = "$($target)Images"
Create "$images\Tiles"
Create "$images\Themes"
CopyFiles "$($solution)Resources\Generated\Tiles" "*" "$images\Tiles"
CopyFiles "$($project)\Images\Themes" "*" "$images\Themes"
CopyFiles "$($solution)" "CHANGELOG.md" "$($project)Resources"
}
"`nDone."