-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpack.ps1
More file actions
76 lines (60 loc) · 2.27 KB
/
pack.ps1
File metadata and controls
76 lines (60 loc) · 2.27 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<#PSScriptInfo
.VERSION 0.86.0
.GUID 58d7b8e8-fa18-485d-baaf-4c413181280b
.AUTHOR Henrik Lau Eriksson
.COMPANYNAME
.COPYRIGHT
.TAGS PowerToys Run Plugins Pack
.LICENSEURI
.PROJECTURI https://github.com/hlaueriksson/Community.PowerToys.Run.Plugin.Templates
.ICONURI
.EXTERNALMODULEDEPENDENCIES
.REQUIREDSCRIPTS
.EXTERNALSCRIPTDEPENDENCIES
.RELEASENOTES
#>
<#
.Synopsis
Packs the plugins into release archives.
.Description
Builds the solution in Release configuration,
copies the output files into plugin folders,
packs the plugin folders into release archives.
.Example
.\pack.ps1
.Link
https://github.com/hlaueriksson/Community.PowerToys.Run.Plugin.Templates
#>
# Clean
Get-ChildItem -Path "." -Directory -Include "bin", "obj" -Recurse | Remove-Item -Recurse -Force
$dependencies = @("PowerToys.Common.UI.*", "PowerToys.ManagedCommon.*", "PowerToys.Settings.UI.Lib.*", "Wox.Infrastructure.*", "Wox.Plugin.*")
# Plugins
$folders = Get-ChildItem -Recurse -Filter "plugin.json" | Where-Object { $_.FullName -notlike "*\bin\*" } | ForEach-Object { $_.Directory } | Sort-Object -Unique
Write-Output "Pack:"
foreach ($folder in $folders) {
Write-Output "- $($folder.Name)"
$name = $($folder.Name.Split(".")[-1])
# Version
$json = Get-Content -Path (Join-Path $folder.FullName "plugin.json") -Raw | ConvertFrom-Json
$version = $json.Version
Write-Output "Version: $version"
# Platforms
[xml]$csproj = Get-Content -Path (Join-Path $folder.FullName "*.csproj")
$targetFramework = $csproj.Project.PropertyGroup.TargetFramework
$platforms = "$($csproj.Project.PropertyGroup.Platforms)".Trim() -split ";"
foreach ($platform in $platforms)
{
Write-Output "Platform: $platform"
# Build
dotnet build $folder -c Release /p:TF_BUILD=true /p:Platform=$platform
if (!$?) {
# Build FAILED.
Exit $LastExitCode
}
$output = "$folder\bin\$platform\Release\$targetFramework\"
$destination = "$folder\bin\$platform\$name"
$zip = "$folder\bin\$platform\$name-$version-$($platform.ToLower()).zip"
Copy-Item -Path $output -Destination $destination -Recurse -Exclude $dependencies
Compress-Archive -Path $destination -DestinationPath $zip
}
}