-
Notifications
You must be signed in to change notification settings - Fork 122
/
publish.ps1
61 lines (54 loc) · 2.21 KB
/
publish.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
# 关闭回显
$ErrorActionPreference = "SilentlyContinue"
$main = "src/STranslate/STranslate.csproj"
$updater = "src/STranslate.Updater/STranslate.Updater.csproj"
$mainProfile = "src/STranslate/Properties/PublishProfiles/FolderProfile.pubxml"
$updaterProfile = "src/STranslate.Updater/Properties/PublishProfiles/FolderProfile.pubxml"
# 检查并删除发布目录
function CheckAndDeletePublishDir($publishDir) {
if (Test-Path $publishDir) {
Write-Host ""
Write-Host "[Cache] Starting clear."
Write-Host "========================================"
Write-Host "[Cache] Deleting existing publish directory $publishDir..."
Write-Host "========================================"
try {
Remove-Item -Path $publishDir -Recurse -Force
Write-Host ""
Write-Host "========================================"
Write-Host "[Cache] Deleted $publishDir successfully."
Write-Host "========================================"
} catch {
Write-Host ""
Write-Host "========================================"
Write-Host "[Cache] Failed to delete $publishDir. Stopping script."
Write-Host "========================================"
exit
}
} else {
Write-Host ""
Write-Host "========================================"
Write-Host "[Cache] $publishDir not existing."
Write-Host "========================================"
}
}
# 将相对发布目录路径转换为绝对路径
$publishDirAbsolute = [System.IO.Path]::GetFullPath("publish")
CheckAndDeletePublishDir $publishDirAbsolute
Write-Host ""
Write-Host "Publishing started."
Write-Host "========================================"
Write-Host "Publishing $main..."
Write-Host "========================================"
dotnet publish $main -c Release -p:PublishProfile=$mainProfile
Write-Host ""
Write-Host "========================================"
Write-Host "Publishing $updater..."
Write-Host "========================================"
dotnet publish $updater -c Release -p:PublishProfile=$updaterProfile
Write-Host ""
Write-Host "========================================"
Write-Host "Publishing completed."
Write-Host "========================================"
# 暂停
# Read-Host -Prompt "Press Enter to continue"