-
Notifications
You must be signed in to change notification settings - Fork 7
/
package.ps1
93 lines (77 loc) · 2.81 KB
/
package.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
param ($vertype = 'patch', $reltype = 'Debug')
Set-StrictMode -Version Latest
write-host "version type $vertype"
Remove-Item .\tmp_release -Force -Recurse
New-Item .\tmp_release -ItemType "directory" -Force
$manifestContent = Get-Content -path .\manifest.json -Raw
if ($reltype -eq "Debug")
{
# mess up manifest so it can't be uploaded to store
$manifestContent = Get-Content -path .\manifest.bad.main.json -Raw
}
$j = $manifestContent | ConvertFrom-Json
$sourceFileContent = Get-Content -path .\PersonalLogisticsPlugin.cs -Raw
$sourceFileContent -match '.*PluginVersion = "(\d+.\d+.\d+)".*'
$old_vernum = $Matches[1]
$v = [version]$old_vernum
write-host "v = $v"
if ($vertype -eq "minor")
{
$new_version = [version]::New($v.Major, $v.Minor + 1, 0)
}
elseif ($vertype -eq "patch")
{
$new_version = [version]::New($v.Major, $v.Minor, $v.Build + 1)
}
elseif ($vertype -eq "major")
{
$new_version = [version]::New($v.Major + 1, 0, 0)
}
elseif ($vertype -eq "none")
{
$new_version = [version]::New($v.Major, $v.Minor, $v.Build)
}
else
{
Write-Host "invalid vertype: should be (major, minor, patch, none), got $vertype"
exit
}
Write-Host "next version $new_version"
$new_version_string = "$([string]::Join(".", $new_version) )";
$sourceFileContent -replace $old_vernum, $new_version_string | Set-Content -Path .\PersonalLogisticsPlugin.cs -NoNewline
#Import-Module -Name ".\Invoke-MsBuild.psm1"
if ($reltype -eq "Release")
{
# Invoke-MsBuild -Path ".\PersonalLogistics.sln" -Params "/target:Build /property:Configuration=Release"
# Start-Process dotnet.exe -ArgumentList "build -c Release" -NoNewWindow -Wait
dotnet build "/property:Configuration=Release"
Copy-Item -Path bin/Release/net48/PersonalLogistics.dll -Destination tmp_release
}
else
{
# Invoke-MsBuild -Path ".\PersonalLogistics.sln" -Params "/target:Build /property:Configuration=Debug"
# Start-Process dotnet.exe -ArgumentList "build" -NoNewWindow -Wait
dotnet build "/property:Configuration=Debug"
Copy-Item -Path bin/Debug/net48/PersonalLogistics.dll -Destination tmp_release
}
Copy-Item readme.md -Destination tmp_release\README.md
if ($reltype -ne "Debug")
{
# prevent this from being uploaded by making sure there is no icon in zip
Copy-Item icon.png -Destination tmp_release
}
Copy-Item pui -Destination tmp_release
$j.version_number = $new_version_string
$j |ConvertTo-Json | Set-Content -Path .\tmp_release\manifest.json
#$compress = @{
# Path = "tmp_release\*"
# CompressionLevel = "Fastest"
# DestinationPath = "tmp_release\PersonalLogistics.zip"
# PassThru = true
#}
Compress-Archive -Path ".\tmp_release\*" -CompressionLevel "Optimal" -DestinationPath "tmp_release\PersonalLogistics.zip"
if ($reltype -ne "Debug")
{
# don't mess up our manifest
Copy-Item .\tmp_release\manifest.json manifest.json
}