-
Notifications
You must be signed in to change notification settings - Fork 1
/
dev_build.ps1
58 lines (58 loc) · 1.68 KB
/
dev_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
# 读取.env文件
$file = Get-Content .env
# 读取版本号和签名证书的密码
$signPwd = $file | Select-String -Pattern "SIGN_SECRET" | ForEach-Object { $_ -replace "SIGN_SECRET=", "" }
$version = $file | Select-String -Pattern "MSIX_VERSION" | ForEach-Object { $_ -replace "MSIX_VERSION=", "" }
# 在已安装的 msix 应用中查找 ShufflePlay
$package = Get-AppxPackage -Name "ShufflePlay"
# 如果已安装 获取版本号
if ($package)
{
$versionGet = $package.Version
}
else
{
$versionGet = 0
}
# 如果版本号与 .env 文件中的版本号一致,不构建
if ($version -eq $versionGet)
{
Write-Output "已安装应用版本与设置版本一致:$version,不执行构建"
exit
}
# 如果版本号低于已安装的版本号,不构建
$vers = $version -split "\."
$versGet = $versionGet -split "\."
for ($i = 0; $i -lt 4; $i++)
{
$veri = [int]$vers[$i]
$verGeti = [int]$versGet[$i]
if ($veri -gt $verGeti)
{
break
}
if ($veri -lt $verGeti)
{
Write-Output "已安装应用版本高于设置版本:$version,不执行构建"
exit
}
}
Write-Output "开始构建应用版本:$version,本地版本: $versionGet"
# 构建命令
$command = "dart run msix:create --version=$version -p $signPwd"
Write-Output "dart run msix:create --version=$version"
Invoke-Expression $command
# 根据外部输入判断是否安装
$install = Read-Host "是否安装应用?(y/n)"
if ($install -eq "y")
{
Write-Output "开始安装应用"
$command = "Add-AppxPackage -Path .\ShufflePlay.msix"
Write-Output $command
Invoke-Expression $command
Write-Output "安装完成"
}
else
{
Write-Output "不安装应用"
}