-
Notifications
You must be signed in to change notification settings - Fork 10
/
build.ps1
116 lines (102 loc) · 3.28 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
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
# Parameters
Param(
[ValidateSet(
"build",
"clean",
"inno"
)]
[Parameter(Mandatory = $false)]
[string]$Action = "x64",
[Parameter(Mandatory = $false)]
[Switch]$WithMsix,
[Parameter(Mandatory = $false)]
[Switch]$Inno
)
function Header {
Write-Output "`n===================================="
}
# For local building
$ErrorActionPreference = "Stop"
$Platform = "x64";
$AppDirectory = $PSScriptRoot;
$RootProjectDirectory = "$(Get-Location)\WslToolbox.UI";
$RootProject = "$RootProjectDirectory\WslToolbox.UI.csproj";
$AppxManifest = "$RootProjectDirectory\Package.appxmanifest";
$AppUuid = 'FalconNL93.WSLToolbox';
$AppName = "WSL Toolbox"
$AppDescription = "WSL Toolbox allows you to manage your WSL Distributions through an easy to use interface."
$AppExecutable = "toolbox.exe";
$AppVersion = '0.6.17.0';
$AppUrl = "https://github.com/FalconNL93/wsltoolbox";
$AppOwner = "FalconNL93"
$SetupOutputFile = "wsltoolbox_${AppVersion}_${Platform}_setup";
$CommandName = $PSCmdlet.MyInvocation.InvocationName;
$ParameterList = (Get-Command -Name $CommandName).Parameters;
foreach ($Parameter in $ParameterList) {
Get-Variable -Name $Parameter.Values.Name -ErrorAction SilentlyContinue;
}
Header
function Publish {
if($WithMsix)
{
[xml]$manifest= get-content "$AppxManifest";
$manifest.Package.Identity.Version = "$AppVersion";
$manifest.save("$AppxManifest");
}
dotnet publish "$RootProject" `
--nologo `
-p:PublishProfile="$Platform" `
-p:Version="$AppVersion" `
-p:FileVersion="$AppVersion" `
-p:AssemblyVersion="$AppVersion" `
-p:GenerateAppxPackageOnBuild=$WithMsix `
-p:AppxPackageDir="$AppDirectory\app\release\$Platform-msix\" `
--self-contained `
-r win-x64 `
-o "$AppDirectory\app\release\$Platform"
}
function CleanSolution {
dotnet clean
Remove-Item "$AppDirectory\app" -Recurse -Verbose -ErrorAction SilentlyContinue
Remove-Item "$AppDirectory\WslToolbox.Core\bin","$AppDirectory\WslToolbox.Core\obj" -Recurse -Verbose -ErrorAction SilentlyContinue
Remove-Item "$AppDirectory\WslToolbox.Msix\bin","$AppDirectory\WslToolbox.Msix\obj" -Recurse -Verbose -ErrorAction SilentlyContinue
Remove-Item "$AppDirectory\WslToolbox.UI\bin","$AppDirectory\WslToolbox.UI\obj" -Recurse -Verbose -ErrorAction SilentlyContinue
Remove-Item "$AppDirectory\WslToolbox.UI.Core\bin","$AppDirectory\WslToolbox.UI.Core\obj" -Recurse -Verbose -ErrorAction SilentlyContinue
}
function InnoSetup {
.\WslToolbox.Setup\build.ps1 `
-AppDirectory "$AppDirectory\app\release\$Platform" `
-AppUuid "$AppUuid" `
-AppName "$AppName" `
-AppDescription "$AppDescription" `
-AppExecutable "$AppExecutable" `
-AppVersion "$AppVersion" `
-AppUrl "$AppUrl" `
-AppOwner "$AppOwner" `
-SetupOutputFile "$SetupOutputFile"
}
Switch ($Action)
{
"clean"
{
CleanSolution;
break;
}
"inno"
{
InnoSetup;
break;
}
default
{
Publish;
if($Inno)
{
InnoSetup;
}
Header;
Write-Output "Output Directory: $AppDirectory\app\release\$Platform\";
Write-Output "AppX Directory: $AppDirectory\app\release\$Platform-msix\";
break;
}
}