forked from dnSpyEx/dnSpy
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.ps1
More file actions
134 lines (111 loc) · 4.14 KB
/
build.ps1
File metadata and controls
134 lines (111 loc) · 4.14 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
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
param(
[ValidateSet("all","netframework","net","net-x86","net-x64")]
[string]$buildtfm = 'all',
[switch]$NoMsbuild
)
$ErrorActionPreference = 'Stop'
$netframework_tfm = 'net48'
$net_tfm = 'net10.0-windows'
$configuration = 'Release'
$net_baseoutput = "dnSpy\dnSpy\bin\$configuration"
$apphostpatcher_dir = "Build\AppHostPatcher"
#
# The reason we don't use dotnet build is that dotnet build doesn't support COM references yet https://github.com/dnSpy/dnSpy/issues/1053
#
function Build-NetFramework {
Write-Host 'Building .NET Framework x86 and x64 binaries'
$outdir = "$net_baseoutput\$netframework_tfm"
if ($NoMsbuild) {
dotnet build -v:m -c $configuration
if ($LASTEXITCODE) { exit $LASTEXITCODE }
}
else {
msbuild -v:m -m -restore -t:Build -p:Configuration=$configuration
if ($LASTEXITCODE) { exit $LASTEXITCODE }
}
# move all files to a bin sub dir but keep the exe files
Rename-Item $outdir bin
New-Item -ItemType Directory $outdir > $null
Move-Item $net_baseoutput\bin $outdir
foreach ($filename in 'dnSpy-x86.exe', 'dnSpy-x86.exe.config', 'dnSpy-x86.pdb',
'dnSpy.exe', 'dnSpy.exe.config', 'dnSpy.pdb',
'dnSpy.Console.exe', 'dnSpy.Console.exe.config', 'dnSpy.Console.pdb') {
Move-Item $outdir\bin\$filename $outdir
}
}
function Build-Net {
Write-Host 'Building .NET x86 and x64 binaries'
$outdir = "$net_baseoutput\$net_tfm"
if ($NoMsbuild) {
dotnet build -v:m -c $configuration -f $net_tfm
if ($LASTEXITCODE) { exit $LASTEXITCODE }
}
else {
msbuild -v:m -m -restore -t:Build -p:Configuration=$configuration -p:TargetFramework=$net_tfm
if ($LASTEXITCODE) { exit $LASTEXITCODE }
}
Write-Host "Patching .NET apphosts"
# move all files to a bin sub dir but keep the exe apphosts
Rename-Item $outdir bin
New-Item -ItemType Directory $outdir > $null
Move-Item $net_baseoutput\bin $outdir
foreach ($exe in 'dnSpy.exe', 'dnSpy-x86.exe', 'dnSpy.Console.exe') {
Move-Item $outdir\bin\$exe $outdir
& $apphostpatcher_dir\bin\$configuration\$netframework_tfm\AppHostPatcher.exe $outdir\$exe -d bin
if ($LASTEXITCODE) { exit $LASTEXITCODE }
}
}
function Build-SelfContainedNet {
param([string]$arch)
Write-Host "Building self contained .NET $arch binaries"
$rid = "win-$arch"
$outdir = "$net_baseoutput\$net_tfm\$rid"
$publishDir = "$outdir\publish"
if ($NoMsbuild) {
dotnet publish -v:m -c $configuration -f $net_tfm -r $rid --self-contained
if ($LASTEXITCODE) { exit $LASTEXITCODE }
}
else {
msbuild -v:m -m -restore -t:Publish -p:Configuration=$configuration -p:TargetFramework=$net_tfm -p:RuntimeIdentifier=$rid -p:SelfContained=True
if ($LASTEXITCODE) { exit $LASTEXITCODE }
}
Write-Host "Patching self contained .NET $arch apphosts"
# move all files to a bin sub dir but keep the exe apphosts
$tmpbin = 'tmpbin'
Rename-Item $publishDir $tmpbin
New-Item -ItemType Directory $publishDir > $null
Move-Item $outdir\$tmpbin $publishDir
Rename-Item $publishDir\$tmpbin bin
foreach ($exe in 'dnSpy.exe', 'dnSpy.Console.exe') {
Move-Item $publishDir\bin\$exe $publishDir
& $apphostpatcher_dir\bin\$configuration\$netframework_tfm\AppHostPatcher.exe $publishDir\$exe -d bin
if ($LASTEXITCODE) { exit $LASTEXITCODE }
}
}
$buildNetFramework = $buildtfm -eq 'all' -or $buildtfm -eq 'netframework'
$buildNet = $buildtfm -eq 'all' -or $buildtfm -eq 'net'
$buildNetX86 = $buildtfm -eq 'all' -or $buildtfm -eq 'net-x86'
$buildNetX64 = $buildtfm -eq 'all' -or $buildtfm -eq 'net-x64'
if ($buildNetX86 -or $buildNetX64 -or $buildNet) {
Write-Host 'Building AppHostPatcher tool'
if ($NoMsbuild) {
dotnet build -v:m -c $configuration -f $netframework_tfm $apphostpatcher_dir\AppHostPatcher.csproj
if ($LASTEXITCODE) { exit $LASTEXITCODE }
}
else {
msbuild -v:m -m -restore -t:Build -p:Configuration=$configuration -p:TargetFramework=$netframework_tfm $apphostpatcher_dir\AppHostPatcher.csproj
if ($LASTEXITCODE) { exit $LASTEXITCODE }
}
}
if ($buildNetFramework) {
Build-NetFramework
}
if ($buildNet) {
Build-Net
}
if ($buildNetX86) {
Build-SelfContainedNet x86
}
if ($buildNetX64) {
Build-SelfContainedNet x64
}