-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
createpublishedzip.ps1
108 lines (104 loc) · 3.16 KB
/
createpublishedzip.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
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
param(
[String]$os = "win10;linux;osx",
[String]$arch = "x64",
[String]$configuration = "Release",
[bool]$createzip = $True,
[String]$selfcontained = "both"
)
function Build-SFP
{
param (
[string]$TargetRuntime,
[bool]$selfContained = $True,
[bool]$bundle = $False
)
Remove-Item -Path "./$configuration/publish" -Recurse -Force -ErrorAction Ignore
[String[]]$selfContainedFlag = if ($selfContained)
{
"--self-contained"
}
else
{
"--no-self-contained -p:PublishTrimmed=false".Split(" ")
}
[String[]]$bundleFlag = if ($TargetRuntime.StartsWith("osx") -and $bundle)
{
"-p:PublishSingleFile=false -p:IncludeNativeLibrariesForSelfExtract=false".Split(" ")
}
else
{
""
}
dotnet publish "SFP_UI/SFP_UI.csproj" --configuration $configuration --output $configuration/publish --runtime $TargetRuntime @selfContainedFlag @bundleFlag
if ($TargetRuntime.StartsWith("osx") -and $bundle)
{
New-Item -Path "$configuration/publish/SFP_UI.app/Contents/Resources" -ItemType Directory -Force
New-Item -Path "$configuration/publish/SFP_UI.app/Contents/MacOS" -ItemType Directory -Force
Copy-Item -Path "./SFP_UI/RawAssets/SFP-logo.icns" -Destination "$configuration/publish/SFP_UI.app/Contents/Resources/SFP-logo.icns" -Force
Copy-Item -Path "./SFP_UI/RawAssets/Info.plist" -Destination "$configuration/publish/SFP_UI.app/Contents/Info.plist" -Force
Get-ChildItem "$configuration/publish/*" -Exclude "SFP_UI.app" | Move-Item -Destination "$configuration/publish/SFP_UI.app/Contents/MacOS" -Force
if ($IsMacOS)
{
xattr -c "$configuration/publish/SFP_UI.app"
}
}
if ($createzip)
{
$excludeFiles = "*.log", "*.pdb", "*.config"
$publishDir = Join-Path "." "$configuration" "publish"
if ($TargetRuntime.StartsWith("win")) {
$zipname = if ($selfContained)
{
"SFP_UI-$TargetRuntime-SelfContained.zip"
}
else
{
"SFP_UI-$TargetRuntime-net7.zip"
}
Get-ChildItem "$publishDir/*" -Recurse -Exclude $excludeFiles | Compress-Archive -DestinationPath "./$configuration/$zipname" -Force
} else {
$zipname = if ($selfContained)
{
"SFP_UI-$TargetRuntime-SelfContained.tar.gz"
}
else
{
"SFP_UI-$TargetRuntime-net7.tar.gz"
}
$excludeOptions = ""
foreach ($file in $excludeFiles) {
$excludeOptions += "--exclude=""$file"" "
}
$output = if ($TargetRuntime.StartsWith("osx") -and $bundle)
{
"SFP_UI.app"
}
else
{
"."
}
$tarCommand = "tar $excludeOptions -czvf ""./$configuration/$zipname"" -C ""$publishDir"" $output"
Invoke-Expression $tarCOmmand
}
}
}
foreach ($currentOS in $os.Split(";"))
{
$targetRuntime = "$currentOS-$arch"
switch ( $selfcontained.ToLower())
{
{ @("yes", "true", "1") -contains $_ } {
$selfcontainedValues = $True
}
{ @("no", "false", "0") -contains $_ } {
$selfcontainedValues = $False
}
"both" {
$selfcontainedValues = $False, $True
}
}
foreach ($value in $selfcontainedValues)
{
Build-SFP -TargetRuntime $targetRuntime -selfContained $value
}
}