forked from chr233/ASFEnhance
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.ps1
94 lines (65 loc) · 2.71 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
$projectName = "ASFEnhance";
$tmpFolder = ".\tmp";
$distFolder = ".\dist";
$objFolder = ".\$projectName\obj";
$local = "Localization"
$localizationFolder = ".\$projectName\$local";
$backupFolder = "$tmpFolder\$local";
$slnFileName = ".\$projectName.sln";
$languages = "en-US", "zh-Hans";
#判断工作目录
if (!(Test-Path $slnFileName)) {
Write-Output "please run at $projectName's root path";
[Console]::Readkey() | Out-Null;
Exit;
}
if (!(Test-Path $tmpFolder)) {
Write-Output "Create folder $tmpFolder";
New-Item -ItemType Directory -Path $tmpFolder -Force
}
if (!(Test-Path $distFolder)) {
Write-Output "Create folder $distFolder";
New-Item -ItemType Directory -Path $distFolder -Force;
}
Write-Output "Backup localizationization files";
Copy-Item -Path "$localizationFolder" -Destination "$tmpFolder" -Force -Recurse;
# Write-Output "Clear language resx files";
# Remove-Item -Path "$localizationFolder\Langs.[a-z]*-[a-z]*.resx" -Recurse -Force;
foreach ($lang in $languages) {
Write-Output "Start to build $lang Version";
$outFolder = "$tmpFolder\$lang";
$distFile = "$outFolder\$projectName.dll";
if ((Test-Path $objFolder)) {
# Remove-Item -Path "$outFolder" -Recurse -Force;
&cmd.exe /c rd /s /q $objFolder;
}
if ((Test-Path $outFolder)) {
# Remove-Item -Path "$outFolder" -Recurse -Force;
&cmd.exe /c rd /s /q $outFolder;
}
Copy-Item -Path "$backupFolder\Langs.$lang.resx" -Destination "$localizationFolder\Langs.resx" -Force;
dotnet publish $projectName -c "Release" -f "net6.0" -o "$outFolder";
if ((Test-Path $distFile)) {
$version = [System.Diagnostics.FileVersionInfo]::GetVersionInfo("$distFile").FileVersion;
Copy-Item -Path "$outFolder\$projectName.dll" -Destination "$distFolder\$projectName-$lang.dll" -Force;
# Remove-Item -Path "$outFolder" -Recurse -Force;
Write-Output "Build Language $lang Version $version complete";
}
else {
Write-Output "Build Language $lang Version UNKNOWN failed";
}
Write-Output "###############################################################";
}
Write-Output "Restore localization files";
Move-Item -Path "$backupFolder\*" -Destination "$localizationFolder" -Force;
# Create the final zip file
Get-ChildItem $distFolder -Filter *.dll | ForEach-Object -Process {
$fileName = $_.Name;
$pureName = $fileName.Substring(0, $fileName.Length - 4);
Write-Output "Ziping $fileName to $projectName.dll";
Copy-Item -Path "$distFolder\$fileName" -Destination "$distFolder\$projectName.dll" -Force;
7z a -bd -slp -tzip -mm=Deflate -mx=9 -mfb=258 -mpass=15 "$distFolder\$pureName.zip" "$distFolder\$projectName.dll"
}
Remove-Item -Path "$distFolder\$projectName.dll" -Force;
Write-Output "Script run finished";
Exit;