-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathReleaseBuild.ps1
More file actions
57 lines (45 loc) · 2.21 KB
/
ReleaseBuild.ps1
File metadata and controls
57 lines (45 loc) · 2.21 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
# Removes empty static web assets files
function Remove-EmptyStaticWebAssetsFiles {
param (
[string]$folder
)
Get-ChildItem "$folder\*.staticwebassets.endpoints.json" | ForEach-Object {
$content = Get-Content $_.FullName -Raw
if ($content -eq '{"Version":1,"ManifestType":"Publish","Endpoints":[]}') {
Remove-Item $_.FullName -Force
}
}
}
# Get version
$projectFilePath = "src\mGBAHttp\mGBAHttp.csproj"
$xml = [xml](Get-Content $projectFilePath)
$version = $xml.Project.PropertyGroup.Version[0]
# Enforce lua script
$luaVersionLine = (Get-Content "mGBASocketServer.lua")[2];
$luaVersion = ($luaVersionLine -split ' ')[2].Trim()
if ($luaVersion -ne $version){
throw "mGBASocketServer.lua version should be $($version). Currently is $($luaVersion)";
}
# Setup publish variables
$filenamePrefix = "mGBA-http-{0}" -f $version
$rids = @("win-x86","win-x64", "win-arm64", "linux-arm", "linux-arm64", "linux-x64", "osx-x64", "osx-arm64")
foreach ($folder in @(".\release", ".\releaseStaging")) {
if (Test-Path $folder) {
Remove-Item "$folder\*" -Recurse -Force -ErrorAction SilentlyContinue
} else {
New-Item -Path $folder -ItemType Directory | Out-Null
}
}
# Create releases
foreach ($rid in $rids) {
dotnet publish src\mGBAHttp\mGBAHttp.csproj -r $rid -p:SelfContained=false -p:PublishSingleFile=true -p:DebugType=None -p:DebugSymbols=false -o .\releaseStaging -p:AssemblyName="$($filenamePrefix)-$($rid)"
Remove-EmptyStaticWebAssetsFiles -folder ".\releaseStaging"
Move-Item -Path ".\releaseStaging\*.*" -Destination ".\release" -Force
dotnet publish src\mGBAHttp\mGBAHttp.csproj -r $rid -p:SelfContained=true -p:PublishSingleFile=true -p:DebugType=None -p:DebugSymbols=false -o .\releaseStaging -p:AssemblyName="$($filenamePrefix)-$($rid)-self-contained" -p:TrimMode=partial -p:PublishTrimmed=false -p:IncludeAllContentForSelfExtract=true -p:JsonSerializerIsReflectionEnabledByDefault=true
Remove-EmptyStaticWebAssetsFiles -folder ".\releaseStaging"
Move-Item -Path ".\releaseStaging\*.*" -Destination ".\release" -Force
}
# Copy over lua script
Copy-Item -Path ".\mGBASocketServer.lua" -Destination ".\release" -Force
# Cleanup
Remove-Item .\releaseStaging -Recurse -Force