forked from HMBSbige/ShadowsocksR-Windows
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.ps1
68 lines (51 loc) · 1.8 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
param([string]$buildtfm = 'all')
$ErrorActionPreference = 'Stop'
Write-Host 'dotnet SDK version'
dotnet --version
$exe = 'ShadowsocksR.exe'
$netcore_tfm = 'netcoreapp3.1'
$configuration = 'Release'
$output_dir = "shadowsocks-csharp\bin\$configuration"
$dllpatcher_dir = "Build\DotNetDllPathPatcher"
$proj_path = 'shadowsocks-csharp\shadowsocksr.csproj'
$buildCore = $buildtfm -eq 'all' -or $buildtfm -eq 'core'
$buildCoreX86 = $buildtfm -eq 'all' -or $buildtfm -eq 'core-x86'
$buildCoreX64 = $buildtfm -eq 'all' -or $buildtfm -eq 'core-x64'
function Build-NetCore
{
Write-Host 'Building .NET Core'
$outdir = "$output_dir\$netcore_tfm"
$publishDir = "$outdir\publish"
Remove-Item $publishDir -Recurse -Force -Confirm:$false -ErrorAction Ignore
dotnet publish -c $configuration -f $netcore_tfm $proj_path
if ($LASTEXITCODE) { exit $LASTEXITCODE }
& $dllpatcher_dir\bin\$configuration\$netcore_tfm\DotNetDllPathPatcher.exe $publishDir\$exe bin
if ($LASTEXITCODE) { exit $LASTEXITCODE }
}
function Build-NetCoreSelfContained
{
param([string]$arch)
Write-Host "Building .NET Core $arch"
$rid = "win-$arch"
$outdir = "$output_dir\$netcore_tfm\$rid"
$publishDir = "$outdir\publish"
Remove-Item $publishDir -Recurse -Force -Confirm:$false -ErrorAction Ignore
dotnet publish -c $configuration -f $netcore_tfm -r $rid --self-contained true $proj_path
if ($LASTEXITCODE) { exit $LASTEXITCODE }
& $dllpatcher_dir\bin\$configuration\$netcore_tfm\DotNetDllPathPatcher.exe $publishDir\$exe bin
if ($LASTEXITCODE) { exit $LASTEXITCODE }
}
dotnet build -c $configuration -f $netcore_tfm $dllpatcher_dir\DotNetDllPathPatcher.csproj
if ($LASTEXITCODE) { exit $LASTEXITCODE }
if ($buildCore)
{
Build-NetCore
}
if ($buildCoreX86)
{
Build-NetCoreSelfContained x86
}
if ($buildCoreX64)
{
Build-NetCoreSelfContained x64
}