Merge remote-tracking branch 'origin/dev' into PluginPriority

This commit is contained in:
Jeremy Wu 2021-01-07 13:36:31 +11:00
commit 012d2d05f2
17 changed files with 147 additions and 94 deletions

View file

Before

Width:  |  Height:  |  Size: 62 KiB

After

Width:  |  Height:  |  Size: 62 KiB

View file

@ -30,7 +30,7 @@ namespace Flow.Launcher.Infrastructure
public static string PythonPath; public static string PythonPath;
public static readonly string QueryTextBoxIconImagePath = $"{ProgramDirectory}\\Images\\mainsearch.png"; public static readonly string QueryTextBoxIconImagePath = $"{ProgramDirectory}\\Images\\mainsearch.svg";
public const string DefaultTheme = "Darker"; public const string DefaultTheme = "Darker";

View file

@ -75,23 +75,31 @@ namespace Flow.Launcher.Infrastructure.Http
}; };
} }
public static async Task Download([NotNull] string url, [NotNull] string filePath) public static async Task DownloadAsync([NotNull] string url, [NotNull] string filePath)
{ {
using var response = await client.GetAsync(url); try
if (response.StatusCode == HttpStatusCode.OK)
{ {
await using var fileStream = new FileStream(filePath, FileMode.CreateNew); using var response = await client.GetAsync(url);
await response.Content.CopyToAsync(fileStream); if (response.StatusCode == HttpStatusCode.OK)
{
await using var fileStream = new FileStream(filePath, FileMode.CreateNew);
await response.Content.CopyToAsync(fileStream);
}
else
{
throw new HttpRequestException($"Error code <{response.StatusCode}> returned from <{url}>");
}
} }
else catch (HttpRequestException e)
{ {
throw new HttpRequestException($"Error code <{response.StatusCode}> returned from <{url}>"); Log.Exception("Infrastructure.Http", "Http Request Error", e, "DownloadAsync");
throw;
} }
} }
/// <summary> /// <summary>
/// Asynchrously get the result as string from url. /// Asynchrously get the result as string from url.
/// When supposing the result is long and large, try using GetStreamAsync to avoid reading as string /// When supposing the result larger than 83kb, try using GetStreamAsync to avoid reading as string
/// </summary> /// </summary>
/// <param name="url"></param> /// <param name="url"></param>
/// <returns></returns> /// <returns></returns>
@ -101,19 +109,33 @@ namespace Flow.Launcher.Infrastructure.Http
return GetAsync(new Uri(url.Replace("#", "%23"))); return GetAsync(new Uri(url.Replace("#", "%23")));
} }
/// <summary>
/// Asynchrously get the result as string from url.
/// When supposing the result larger than 83kb, try using GetStreamAsync to avoid reading as string
/// </summary>
/// <param name="url"></param>
/// <returns></returns>
public static async Task<string> GetAsync([NotNull] Uri url) public static async Task<string> GetAsync([NotNull] Uri url)
{ {
Log.Debug($"|Http.Get|Url <{url}>"); Log.Debug($"|Http.Get|Url <{url}>");
using var response = await client.GetAsync(url); try
var content = await response.Content.ReadAsStringAsync();
if (response.StatusCode == HttpStatusCode.OK)
{ {
return content; using var response = await client.GetAsync(url);
var content = await response.Content.ReadAsStringAsync();
if (response.StatusCode == HttpStatusCode.OK)
{
return content;
}
else
{
throw new HttpRequestException(
$"Error code <{response.StatusCode}> with content <{content}> returned from <{url}>");
}
} }
else catch (HttpRequestException e)
{ {
throw new HttpRequestException( Log.Exception("Infrastructure.Http", "Http Request Error", e, "GetAsync");
$"Error code <{response.StatusCode}> with content <{content}> returned from <{url}>"); throw;
} }
} }
@ -124,9 +146,17 @@ namespace Flow.Launcher.Infrastructure.Http
/// <returns></returns> /// <returns></returns>
public static async Task<Stream> GetStreamAsync([NotNull] string url) public static async Task<Stream> GetStreamAsync([NotNull] string url)
{ {
Log.Debug($"|Http.Get|Url <{url}>"); try
var response = await client.GetAsync(url); {
return await response.Content.ReadAsStreamAsync(); Log.Debug($"|Http.Get|Url <{url}>");
var response = await client.GetAsync(url);
return await response.Content.ReadAsStreamAsync();
}
catch (HttpRequestException e)
{
Log.Exception("Infrastructure.Http", "Http Request Error", e, "GetStreamAsync");
throw;
}
} }
} }
} }

View file

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop"> <Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup> <PropertyGroup>
<OutputType>WinExe</OutputType> <OutputType>WinExe</OutputType>
@ -81,7 +81,8 @@
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="PropertyChanged.Fody" Version="2.5.13" /> <PackageReference Include="PropertyChanged.Fody" Version="3.3.1" />
<PackageReference Include="SharpVectors" Version="1.7.1" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@ -93,8 +94,4 @@
<Target Name="PreBuild" BeforeTargets="PreBuildEvent"> <Target Name="PreBuild" BeforeTargets="PreBuildEvent">
<Exec Command="taskkill /f /fi &quot;IMAGENAME eq Flow.Launcher.exe&quot;" /> <Exec Command="taskkill /f /fi &quot;IMAGENAME eq Flow.Launcher.exe&quot;" />
</Target> </Target>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="powershell.exe -NoProfile -ExecutionPolicy Bypass -File $(SolutionDir)Scripts\post_build.ps1 $(ConfigurationName) $(SolutionDir) $(TargetPath)" />
</Target>
</Project> </Project>

View file

@ -0,0 +1,10 @@
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg version="1.0" xmlns="http://www.w3.org/2000/svg" width="1200px" height="1200px" viewBox="0 0 12000 12000" preserveAspectRatio="xMidYMid meet">
<g id="layer101" fill="#000000" stroke="none">
</g>
<g id="layer102" fill="#555555" stroke="none">
<path d="M10354 10962 c-28 -11 -75 -35 -105 -55 -33 -21 -773 -754 -1879 -1861 -1004 -1004 -1829 -1826 -1834 -1826 -4 0 -38 22 -75 48 -248 179 -578 351 -869 453 -398 139 -790 198 -1232 185 -748 -20 -1407 -259 -2020 -732 -209 -161 -508 -475 -676 -709 -270 -377 -476 -847 -567 -1295 -53 -261 -67 -406 -67 -700 0 -340 26 -556 105 -861 128 -499 376 -976 715 -1374 86 -101 312 -324 410 -406 521 -434 1162 -709 1830 -784 181 -20 577 -20 758 0 657 75 1252 323 1782 744 144 114 451 426 556 566 176 233 281 404 393 635 223 465 332 947 332 1470 0 394 -50 705 -174 1082 -53 160 -62 182 -135 343 -85 186 -212 407 -332 575 -28 39 -50 73 -50 78 0 4 826 833 1835 1842 1386 1386 1843 1849 1869 1894 21 34 42 90 52 134 14 64 15 85 4 146 -28 163 -140 311 -290 383 -69 34 -83 37 -180 40 -85 3 -115 0 -156 -15z m-5669 -3912 c529 -49 1009 -241 1415 -566 109 -88 296 -275 384 -384 667 -833 762 -1990 237 -2910 -352 -619 -923 -1053 -1621 -1234 -394 -101 -878 -101 -1270 1 -382 99 -690 253 -992 496 -501 402 -828 974 -930 1627 -31 194 -31 576 0 770 40 255 120 520 225 740 326 682 944 1192 1677 1383 157 41 275 61 480 80 81 8 293 6 395 -3z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

View file

@ -74,7 +74,7 @@
<system:String x:Key="deleteCustomHotkeyWarning">Are you sure you want to delete {0} plugin hotkey?</system:String> <system:String x:Key="deleteCustomHotkeyWarning">Are you sure you want to delete {0} plugin hotkey?</system:String>
<system:String x:Key="queryWindowShadowEffect">Query window shadow effect</system:String> <system:String x:Key="queryWindowShadowEffect">Query window shadow effect</system:String>
<system:String x:Key="shadowEffectCPUUsage">Shadow effect has a substantial usage of GPU.</system:String> <system:String x:Key="shadowEffectCPUUsage">Shadow effect has a substantial usage of GPU.</system:String>
<system:String x:Key="shadowEffectPerformance">Not recommended if you computer performance is limited.</system:String> <system:String x:Key="shadowEffectPerformance">Not recommended if your computer performance is limited.</system:String>
<!--Setting Proxy--> <!--Setting Proxy-->
<system:String x:Key="proxy">HTTP Proxy</system:String> <system:String x:Key="proxy">HTTP Proxy</system:String>

View file

@ -6,6 +6,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:converters="clr-namespace:Flow.Launcher.Converters" xmlns:converters="clr-namespace:Flow.Launcher.Converters"
xmlns:svgc="http://sharpvectors.codeplex.com/svgc/"
mc:Ignorable="d" mc:Ignorable="d"
Title="Flow Launcher" Title="Flow Launcher"
Topmost="True" Topmost="True"
@ -92,7 +93,8 @@
</ContextMenu> </ContextMenu>
</TextBox.ContextMenu> </TextBox.ContextMenu>
</TextBox> </TextBox>
<Image Source="{Binding Image, IsAsync=True}" Width="48" HorizontalAlignment="Right" /> <svgc:SvgControl Source="{Binding Image}" HorizontalAlignment="Right" Width="48" Height="48"
Background="Transparent"/>
</Grid> </Grid>
<Line x:Name="ProgressBar" HorizontalAlignment="Right" <Line x:Name="ProgressBar" HorizontalAlignment="Right"
Style="{DynamicResource PendingLineStyle}" Visibility="{Binding ProgressBarVisibility, Mode=TwoWay}" Style="{DynamicResource PendingLineStyle}" Visibility="{Binding ProgressBarVisibility, Mode=TwoWay}"

View file

@ -8,6 +8,7 @@
xmlns:userSettings="clr-namespace:Flow.Launcher.Infrastructure.UserSettings;assembly=Flow.Launcher.Infrastructure" xmlns:userSettings="clr-namespace:Flow.Launcher.Infrastructure.UserSettings;assembly=Flow.Launcher.Infrastructure"
xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:ui="http://schemas.modernwpf.com/2019" xmlns:ui="http://schemas.modernwpf.com/2019"
xmlns:svgc="http://sharpvectors.codeplex.com/svgc/"
x:Class="Flow.Launcher.SettingWindow" x:Class="Flow.Launcher.SettingWindow"
mc:Ignorable="d" mc:Ignorable="d"
Icon="Images\app.png" Icon="Images\app.png"
@ -256,7 +257,8 @@
Text="{DynamicResource hiThere}" IsReadOnly="True" Text="{DynamicResource hiThere}" IsReadOnly="True"
Style="{DynamicResource QueryBoxStyle}" Style="{DynamicResource QueryBoxStyle}"
Margin="18 0 56 0" /> Margin="18 0 56 0" />
<Image Source="{Binding ThemeImage}" HorizontalAlignment="Right" /> <svgc:SvgControl Source="{Binding ThemeImage}" Height="48" Width="48" HorizontalAlignment="Right"
Background="Transparent" />
<ContentControl Grid.Row="1"> <ContentControl Grid.Row="1">
<flowlauncher:ResultListBox DataContext="{Binding PreviewResults, Mode=OneTime}" Visibility="Visible" /> <flowlauncher:ResultListBox DataContext="{Binding PreviewResults, Mode=OneTime}" Visibility="Visible" />
</ContentControl> </ContentControl>

View file

@ -285,7 +285,7 @@ namespace Flow.Launcher.ViewModel
public string OpenResultCommandModifiers { get; private set; } public string OpenResultCommandModifiers { get; private set; }
public ImageSource Image => ImageLoader.Load(Constant.QueryTextBoxIconImagePath); public string Image => Constant.QueryTextBoxIconImagePath;
#endregion #endregion

View file

@ -1,4 +1,5 @@
using System; using System;
using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows; using System.Windows;
using System.Windows.Media; using System.Windows.Media;
@ -12,9 +13,9 @@ namespace Flow.Launcher.ViewModel
{ {
public class ResultViewModel : BaseModel public class ResultViewModel : BaseModel
{ {
public class LazyAsync<T> : Lazy<Task<T>> public class LazyAsync<T> : Lazy<ValueTask<T>>
{ {
private T defaultValue; private readonly T defaultValue;
private readonly Action _updateCallback; private readonly Action _updateCallback;
public new T Value public new T Value
@ -23,21 +24,27 @@ namespace Flow.Launcher.ViewModel
{ {
if (!IsValueCreated) if (!IsValueCreated)
{ {
base.Value.ContinueWith(_ => _ = Exercute(); // manually use callback strategy
{
_updateCallback();
});
return defaultValue; return defaultValue;
} }
if (!base.Value.IsCompleted || base.Value.IsFaulted) if (!base.Value.IsCompletedSuccessfully)
return defaultValue; return defaultValue;
return base.Value.Result; return base.Value.Result;
// If none of the variables captured by the local function are captured by other lambdas,
// the compiler can avoid heap allocations.
async ValueTask Exercute()
{
await base.Value.ConfigureAwait(false);
_updateCallback();
}
} }
} }
public LazyAsync(Func<Task<T>> factory, T defaultValue, Action updateCallback) : base(factory) public LazyAsync(Func<ValueTask<T>> factory, T defaultValue, Action updateCallback) : base(factory)
{ {
if (defaultValue != null) if (defaultValue != null)
{ {
@ -55,13 +62,13 @@ namespace Flow.Launcher.ViewModel
Result = result; Result = result;
Image = new LazyAsync<ImageSource>( Image = new LazyAsync<ImageSource>(
SetImage, SetImage,
ImageLoader.DefaultImage, ImageLoader.DefaultImage,
() => () =>
{ {
OnPropertyChanged(nameof(Image)); OnPropertyChanged(nameof(Image));
}); });
} }
Settings = settings; Settings = settings;
} }
@ -82,7 +89,7 @@ namespace Flow.Launcher.ViewModel
public LazyAsync<ImageSource> Image { get; set; } public LazyAsync<ImageSource> Image { get; set; }
private async Task<ImageSource> SetImage() private async ValueTask<ImageSource> SetImage()
{ {
var imagePath = Result.IcoPath; var imagePath = Result.IcoPath;
if (string.IsNullOrEmpty(imagePath) && Result.Icon != null) if (string.IsNullOrEmpty(imagePath) && Result.Icon != null)
@ -94,7 +101,7 @@ namespace Flow.Launcher.ViewModel
catch (Exception e) catch (Exception e)
{ {
Log.Exception($"|ResultViewModel.Image|IcoPath is empty and exception when calling Icon() for result <{Result.Title}> of plugin <{Result.PluginDirectory}>", e); Log.Exception($"|ResultViewModel.Image|IcoPath is empty and exception when calling Icon() for result <{Result.Title}> of plugin <{Result.PluginDirectory}>", e);
imagePath = Constant.MissingImgIcon; return ImageLoader.DefaultImage;
} }
} }

View file

@ -439,7 +439,7 @@ namespace Flow.Launcher.ViewModel
} }
} }
public ImageSource ThemeImage => ImageLoader.Load(Constant.QueryTextBoxIconImagePath); public string ThemeImage => Constant.QueryTextBoxIconImagePath;
#endregion #endregion

View file

@ -11,6 +11,7 @@
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath> <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath> <AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">

View file

@ -7,6 +7,7 @@
<UseWindowsForms>true</UseWindowsForms> <UseWindowsForms>true</UseWindowsForms>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath> <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
<ApplicationIcon /> <ApplicationIcon />
<StartupObject /> <StartupObject />
</PropertyGroup> </PropertyGroup>

View file

@ -10,6 +10,7 @@
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath> <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath> <AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">

View file

@ -127,7 +127,7 @@ namespace Flow.Launcher.Plugin.PluginsManager
Context.API.ShowMsg(Context.API.GetTranslation("plugin_pluginsmanager_downloading_plugin"), Context.API.ShowMsg(Context.API.GetTranslation("plugin_pluginsmanager_downloading_plugin"),
Context.API.GetTranslation("plugin_pluginsmanager_please_wait")); Context.API.GetTranslation("plugin_pluginsmanager_please_wait"));
await Http.Download(plugin.UrlDownload, filePath).ConfigureAwait(false); await Http.DownloadAsync(plugin.UrlDownload, filePath).ConfigureAwait(false);
Context.API.ShowMsg(Context.API.GetTranslation("plugin_pluginsmanager_downloading_plugin"), Context.API.ShowMsg(Context.API.GetTranslation("plugin_pluginsmanager_downloading_plugin"),
Context.API.GetTranslation("plugin_pluginsmanager_download_success")); Context.API.GetTranslation("plugin_pluginsmanager_download_success"));
@ -217,7 +217,7 @@ namespace Flow.Launcher.Plugin.PluginsManager
Context.API.ShowMsg(Context.API.GetTranslation("plugin_pluginsmanager_downloading_plugin"), Context.API.ShowMsg(Context.API.GetTranslation("plugin_pluginsmanager_downloading_plugin"),
Context.API.GetTranslation("plugin_pluginsmanager_please_wait")); Context.API.GetTranslation("plugin_pluginsmanager_please_wait"));
await Http.Download(x.PluginNewUserPlugin.UrlDownload, downloadToFilePath).ConfigureAwait(false); await Http.DownloadAsync(x.PluginNewUserPlugin.UrlDownload, downloadToFilePath).ConfigureAwait(false);
Context.API.ShowMsg(Context.API.GetTranslation("plugin_pluginsmanager_downloading_plugin"), Context.API.ShowMsg(Context.API.GetTranslation("plugin_pluginsmanager_downloading_plugin"),
Context.API.GetTranslation("plugin_pluginsmanager_download_success")); Context.API.GetTranslation("plugin_pluginsmanager_download_success"));

View file

@ -1,13 +1,13 @@
param( param(
[string]$config = "Release", [string]$config = "Release",
[string]$solution, [string]$solution = (Join-Path $PSScriptRoot ".." -Resolve)
[string]$targetpath
) )
Write-Host "Config: $config" Write-Host "Config: $config"
function Build-Version { function Build-Version {
if ([string]::IsNullOrEmpty($env:flowVersion)) { if ([string]::IsNullOrEmpty($env:flowVersion)) {
$v = (Get-Command ${TargetPath}).FileVersionInfo.FileVersion $targetPath = Join-Path $solution "Output/Release/Flow.Launcher.dll" -Resolve
$v = (Get-Command ${targetPath}).FileVersionInfo.FileVersion
} else { } else {
$v = $env:flowVersion $v = $env:flowVersion
} }
@ -31,13 +31,9 @@ function Build-Path {
return $p return $p
} }
function Copy-Resources ($path, $config) { function Copy-Resources ($path) {
$project = "$path\Flow.Launcher"
$output = "$path\Output"
$target = "$output\$config"
Copy-Item -Recurse -Force $project\Images\* $target\Images\
# making version static as multiple versions can exist in the nuget folder and in the case a breaking change is introduced. # making version static as multiple versions can exist in the nuget folder and in the case a breaking change is introduced.
Copy-Item -Force $env:USERPROFILE\.nuget\packages\squirrel.windows\1.5.2\tools\Squirrel.exe $output\Update.exe Copy-Item -Force $env:USERPROFILE\.nuget\packages\squirrel.windows\1.5.2\tools\Squirrel.exe $path\Output\Update.exe
} }
function Delete-Unused ($path, $config) { function Delete-Unused ($path, $config) {
@ -55,17 +51,6 @@ function Validate-Directory ($output) {
New-Item $output -ItemType Directory -Force New-Item $output -ItemType Directory -Force
} }
function Zip-Release ($path, $version, $output) {
Write-Host "Begin zip release"
$content = "$path\Output\Release\*"
$zipFile = "$output\Flow-Launcher-v$version.zip"
Compress-Archive -Force -Path $content -DestinationPath $zipFile
Write-Host "End zip release"
}
function Pack-Squirrel-Installer ($path, $version, $output) { function Pack-Squirrel-Installer ($path, $version, $output) {
# msbuild based installer generation is not working in appveyor, not sure why # msbuild based installer generation is not working in appveyor, not sure why
Write-Host "Begin pack squirrel installer" Write-Host "Begin pack squirrel installer"
@ -75,6 +60,8 @@ function Pack-Squirrel-Installer ($path, $version, $output) {
Write-Host "Packing: $spec" Write-Host "Packing: $spec"
Write-Host "Input path: $input" Write-Host "Input path: $input"
# making version static as multiple versions can exist in the nuget folder and in the case a breaking change is introduced.
New-Alias Nuget $env:USERPROFILE\.nuget\packages\NuGet.CommandLine\5.4.0\tools\NuGet.exe -Force
# TODO: can we use dotnet pack here? # TODO: can we use dotnet pack here?
nuget pack $spec -Version $version -BasePath $input -OutputDirectory $output -Properties Configuration=Release nuget pack $spec -Version $version -BasePath $input -OutputDirectory $output -Properties Configuration=Release
@ -100,40 +87,30 @@ function Pack-Squirrel-Installer ($path, $version, $output) {
Write-Host "End pack squirrel installer" Write-Host "End pack squirrel installer"
} }
function IsDotNetCoreAppSelfContainedPublishEvent{ function Publish-Self-Contained ($p) {
return Test-Path $solution\Output\Release\coreclr.dll
}
function FixPublishLastWriteDateTimeError ($solutionPath) { $csproj = Join-Path "$p" "Flow.Launcher/Flow.Launcher.csproj" -Resolve
#Fix error from publishing self contained app, when nuget tries to pack core dll references throws the error 'The DateTimeOffset specified cannot be converted into a Zip file timestamp' $profile = Join-Path "$p" "Flow.Launcher/Properties/PublishProfiles/NetCore3.1-SelfContained.pubxml" -Resolve
gci -path "$solutionPath\Output\Release" -rec -file *.dll | Where-Object {$_.LastWriteTime -lt (Get-Date).AddYears(-20)} | % { try { $_.LastWriteTime = '01/01/2000 00:00:00' } catch {} }
# we call dotnet publish on the main project.
# The other projects should have been built in Release at this point.
dotnet publish -c Release $csproj /p:PublishProfile=$profile
} }
function Main { function Main {
$p = Build-Path $p = Build-Path
$v = Build-Version $v = Build-Version
Copy-Resources $p $config Copy-Resources $p
if ($config -eq "Release"){ if ($config -eq "Release"){
if(IsDotNetCoreAppSelfContainedPublishEvent) {
FixPublishLastWriteDateTimeError $p
}
Delete-Unused $p $config Delete-Unused $p $config
Publish-Self-Contained $p
$o = "$p\Output\Packages" $o = "$p\Output\Packages"
Validate-Directory $o Validate-Directory $o
# making version static as multiple versions can exist in the nuget folder and in the case a breaking change is introduced.
New-Alias Nuget $env:USERPROFILE\.nuget\packages\NuGet.CommandLine\5.4.0\tools\NuGet.exe -Force
Pack-Squirrel-Installer $p $v $o Pack-Squirrel-Installer $p $v $o
$isInCI = $env:APPVEYOR
if ($isInCI) {
Zip-Release $p $v $o
}
Write-Host "List output directory"
Get-ChildItem $o
} }
} }

View file

@ -26,17 +26,42 @@ before_build:
build: build:
project: Flow.Launcher.sln project: Flow.Launcher.sln
verbosity: minimal verbosity: minimal
after_build:
- ps: .\Scripts\post_build.ps1
artifacts: artifacts:
- path: 'Output\Packages\Flow-Launcher-*.zip'
name: Zip
- path: 'Output\Release\Flow.Launcher.Plugin.*.nupkg' - path: 'Output\Release\Flow.Launcher.Plugin.*.nupkg'
name: Plugin nupkg name: Plugin nupkg
- path: 'Output\Packages\Flow-Launcher-*.exe'
name: Squirrel Installer
- path: 'Output\Packages\FlowLauncher-*-full.nupkg'
name: Squirrel nupkg
- path: 'Output\Packages\RELEASES'
name: Squirrel RELEASES
deploy: deploy:
provider: NuGet - provider: NuGet
artifact: /.*\.nupkg/ artifact: Plugin nupkg
api_key: api_key:
secure: n80IeWR3pN81p0w4uXq4mO0TdTXoJSHHFL+yTB9YBJ0Wni2DjZGYwOFdaWzW4hRi secure: n80IeWR3pN81p0w4uXq4mO0TdTXoJSHHFL+yTB9YBJ0Wni2DjZGYwOFdaWzW4hRi
on: on:
branch: master branch: master
- provider: GitHub
release: v$(flowVersion)
auth_token:
secure: ij4UeXUYQBDJxn2YRAAhUOjklOGVKDB87Hn5J8tKIzj13yatoI7sLM666QDQFEgv
artifact: Squirrel Installer, Squirrel nupkg, Squirrel RELEASES
draft: true
force_update: true
on:
branch: master
- provider: GitHub
release: v$(flowVersion)
auth_token:
secure: ij4UeXUYQBDJxn2YRAAhUOjklOGVKDB87Hn5J8tKIzj13yatoI7sLM666QDQFEgv
artifact: Squirrel Installer, Squirrel nupkg, Squirrel RELEASES
force_update: true
on:
APPVEYOR_REPO_TAG: true