Flow.Launcher/Scripts/post_build.ps1

159 lines
3.9 KiB
PowerShell
Raw Permalink Normal View History

2017-03-14 20:24:09 +00:00
param(
2024-03-24 18:41:07 +00:00
[string]$config = "Release",
[string]$solution = (Join-Path $PSScriptRoot ".." -Resolve),
2024-03-27 05:46:14 +00:00
[string]$channel = "win-x64-prerelease",
[string]$flowVersion = ""
2017-03-14 20:24:09 +00:00
)
Write-Host "Config: $config"
2024-03-24 18:52:05 +00:00
Write-Host "Solution: $solution"
Write-Host "Flow Version: $flowVersion"
2024-03-24 18:52:05 +00:00
Write-Host "Channel: $channel"
2024-03-24 18:41:07 +00:00
function Build-Version
{
2024-03-27 05:46:14 +00:00
if ( [string]::IsNullOrEmpty($flowVersion))
2024-03-24 18:41:07 +00:00
{
2021-01-04 23:50:19 +00:00
$targetPath = Join-Path $solution "Output/Release/Flow.Launcher.dll" -Resolve
$v = (Get-Command ${targetPath}).FileVersionInfo.FileVersion
2024-03-24 18:41:07 +00:00
}
else
{
$v = $flowVersion
2017-03-13 18:07:49 +00:00
}
Write-Host "Build Version: $v"
return $v
}
2024-03-24 18:41:07 +00:00
function Build-Path
{
if (![string]::IsNullOrEmpty($env:APPVEYOR_BUILD_FOLDER))
{
2017-03-13 18:07:49 +00:00
$p = $env:APPVEYOR_BUILD_FOLDER
2024-03-24 18:41:07 +00:00
}
elseif (![string]::IsNullOrEmpty($solution))
{
$p = $solution
2024-03-24 18:41:07 +00:00
}
else
{
$p = Get-Location
2017-03-13 18:07:49 +00:00
}
Write-Host "Build Folder: $p"
Set-Location $p
return $p
}
2024-03-24 18:41:07 +00:00
function Delete-Unused($path, $config)
{
$target = "$path\Output\$config"
$included = Get-ChildItem $target -Filter "*.dll"
2024-03-26 22:38:29 +00:00
$hashset = @{ }
foreach ($i in $included)
{
2024-03-26 22:38:29 +00:00
$item = if ($i.VersionInfo.FileVersion -eq $null)
{
[ValueTuple]::Create($i.Name, "")
}
else
{
[ValueTuple]::Create($i.Name, $i.VersionInfo.FileVersion)
}
$key = $hashset.Add($item, $true)
}
$deleteList = Get-ChildItem $target\Plugins -Filter *.dll -Recurse | Where {
$item = if ($_.VersionInfo.FileVersion -eq $null)
{
[ValueTuple]::Create($_.Name, "")
}
else
{
[ValueTuple]::Create($_.Name, $_.VersionInfo.FileVersion)
}
$hashset.ContainsKey($item)
}
foreach ($i in $deleteList)
{
2024-03-26 23:15:04 +00:00
write "Deleting duplicated $($i.Name) with version $($i.VersionInfo.FileVersion) at location $($i.Directory.FullName)"
2024-05-03 10:42:47 +00:00
Remove-Item -Path $i.FullName
}
2024-03-24 18:41:07 +00:00
Remove-Item -Path $target -Include "*.xml" -Recurse
}
2021-06-24 04:38:18 +00:00
2024-03-24 18:41:07 +00:00
function Validate-Directory($output)
{
2017-03-13 18:07:49 +00:00
New-Item $output -ItemType Directory -Force
}
2021-06-24 04:38:18 +00:00
function Pack-Velopack-Installer($path, $version, $output)
2024-03-24 18:41:07 +00:00
{
2017-03-13 18:07:49 +00:00
# msbuild based installer generation is not working in appveyor, not sure why
Write-Host "Begin pack squirrel installer"
2020-04-21 12:54:41 +00:00
$spec = "$path\Scripts\flowlauncher.nuspec"
2024-05-03 11:11:25 +00:00
$input = "$path\Output\$config"
Write-Host "Packing: $spec"
2017-03-13 18:07:49 +00:00
Write-Host "Input path: $input"
2024-05-04 04:02:05 +00:00
Write-Host "Output path: $output"
2022-12-08 19:38:13 +00:00
2024-03-24 18:41:07 +00:00
$repoUrl = "https://github.com/Flow-Launcher/Prereleases"
2024-03-24 18:41:07 +00:00
if ($channel -eq "stable")
{
$repoUrl = "https://github.com/Flow-Launcher/Flow.Launcher"
}
2024-03-26 22:45:46 +00:00
Set-Alias vpk "~/.dotnet/tools/vpk.exe"
if (!(Get-Command vpk -ErrorAction SilentlyContinue))
{
dotnet tool install --global vpk
}
2024-05-03 10:54:30 +00:00
# Create UserData folder before Packing
2024-05-04 04:02:05 +00:00
# FIXME userdata should not be created in installer version
# New-Item -ItemType Directory -Force -Path "$input\UserData"
2024-05-03 10:54:30 +00:00
vpk pack --packVersion $version --packDir $input --packId FlowLauncher --mainExe Flow.Launcher.exe --channel $channel --outputDir $output --packTitle "Flow Launcher" --icon "$input\Images\app.ico" --packAuthors "Flow-Launcher Team"
2017-03-13 18:07:49 +00:00
}
2024-03-24 18:41:07 +00:00
function Publish-Self-Contained($p)
{
$csproj = Join-Path "$p" "Flow.Launcher/Flow.Launcher.csproj" -Resolve
2022-12-31 02:38:39 +00:00
$profile = Join-Path "$p" "Flow.Launcher/Properties/PublishProfiles/Net7.0-SelfContained.pubxml" -Resolve
2021-01-04 23:50:19 +00:00
# we call dotnet publish on the main project.
# The other projects should have been built in Release at this point.
2024-03-26 18:37:33 +00:00
dotnet publish $csproj /p:PublishProfile=$profile
2021-07-24 08:08:25 +00:00
}
2024-03-24 18:41:07 +00:00
function Main
{
2017-03-13 18:07:49 +00:00
$p = Build-Path
$v = Build-Version
2017-03-13 18:07:49 +00:00
2024-03-24 18:41:07 +00:00
if ($config -eq "Release")
{
Delete-Unused $p $config
2021-01-04 23:50:19 +00:00
Publish-Self-Contained $p
2024-05-04 04:02:05 +00:00
$o = "$p\Releases"
Validate-Directory $o
Pack-Velopack-Installer $p $v $o
2017-03-13 18:07:49 +00:00
}
}
Main