-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.ps1
More file actions
65 lines (58 loc) · 2.8 KB
/
Copy pathbuild.ps1
File metadata and controls
65 lines (58 loc) · 2.8 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
# HTTP并发测试工具 - 打包脚本
# 生成单文件版本:带 runtime 和不带 runtime,x64 和 x86 平台
Write-Host "开始打包 HTTP 并发测试工具..." -ForegroundColor Green
Write-Host ""
# 创建输出目录
$outputDir = "publish"
if (Test-Path $outputDir) {
Remove-Item -Path $outputDir -Recurse -Force
}
New-Item -ItemType Directory -Path $outputDir | Out-Null
# 打包 x64 带运行时
Write-Host "正在打包: x64 平台 - 带运行时 - 单文件" -ForegroundColor Yellow
dotnet publish -c Release -r win-x64 -p:PublishSingleFile=true -p:SelfContained=true -p:IncludeNativeLibrariesForSelfExtract=true -p:EnableCompressionInSingleFile=true -o "$outputDir/x64_SelfContained"
if ($LASTEXITCODE -eq 0) {
Write-Host "✓ 打包成功: x64_SelfContained" -ForegroundColor Green
} else {
Write-Host "✗ 打包失败: x64_SelfContained" -ForegroundColor Red
}
Write-Host ""
# 打包 x64 不带运行时
Write-Host "正在打包: x64 平台 - 不带运行时 - 单文件" -ForegroundColor Yellow
dotnet publish -c Release -r win-x64 -p:PublishSingleFile=true -p:SelfContained=false -o "$outputDir/x64_FrameworkDependent"
if ($LASTEXITCODE -eq 0) {
Write-Host "✓ 打包成功: x64_FrameworkDependent" -ForegroundColor Green
} else {
Write-Host "✗ 打包失败: x64_FrameworkDependent" -ForegroundColor Red
}
Write-Host ""
# 打包 x86 带运行时
Write-Host "正在打包: x86 平台 - 带运行时 - 单文件" -ForegroundColor Yellow
dotnet publish -c Release -r win-x86 -p:PublishSingleFile=true -p:SelfContained=true -p:IncludeNativeLibrariesForSelfExtract=true -p:EnableCompressionInSingleFile=true -o "$outputDir/x86_SelfContained"
if ($LASTEXITCODE -eq 0) {
Write-Host "✓ 打包成功: x86_SelfContained" -ForegroundColor Green
} else {
Write-Host "✗ 打包失败: x86_SelfContained" -ForegroundColor Red
}
Write-Host ""
# 打包 x86 不带运行时
Write-Host "正在打包: x86 平台 - 不带运行时 - 单文件" -ForegroundColor Yellow
dotnet publish -c Release -r win-x86 -p:PublishSingleFile=true -p:SelfContained=false -o "$outputDir/x86_FrameworkDependent"
if ($LASTEXITCODE -eq 0) {
Write-Host "✓ 打包成功: x86_FrameworkDependent" -ForegroundColor Green
} else {
Write-Host "✗ 打包失败: x86_FrameworkDependent" -ForegroundColor Red
}
Write-Host ""
Write-Host "所有版本打包完成!" -ForegroundColor Green
Write-Host "输出目录: $outputDir" -ForegroundColor Cyan
Write-Host ""
Write-Host "打包结果:" -ForegroundColor Cyan
Get-ChildItem -Path $outputDir -Directory | ForEach-Object {
$exePath = Join-Path $_.FullName "HttpConcurrencyTester.exe"
if (Test-Path $exePath) {
$fileInfo = Get-Item $exePath
$sizeMB = [math]::Round($fileInfo.Length / 1MB, 2)
Write-Host " $($_.Name): $sizeMB MB" -ForegroundColor White
}
}