Trim produced assemblies (#447)
This commit is contained in:
parent
db003aa6ca
commit
0c6e7eb1ac
2
.github/workflows/main.yml
vendored
2
.github/workflows/main.yml
vendored
@ -50,7 +50,7 @@ jobs:
|
||||
- osx-arm64
|
||||
- osx-x64
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ${{ startsWith(matrix.rid, 'win-') && 'windows-latest' || startsWith(matrix.rid, 'osx-') && 'macos-latest' || 'ubuntu-latest' }}
|
||||
timeout-minutes: 10
|
||||
|
||||
permissions:
|
||||
|
@ -1,25 +1,33 @@
|
||||
using System;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.Templates;
|
||||
using YoutubeDownloader.ViewModels;
|
||||
using YoutubeDownloader.ViewModels.Components;
|
||||
using YoutubeDownloader.ViewModels.Dialogs;
|
||||
using YoutubeDownloader.Views;
|
||||
using YoutubeDownloader.Views.Components;
|
||||
using YoutubeDownloader.Views.Dialogs;
|
||||
|
||||
namespace YoutubeDownloader.Framework;
|
||||
|
||||
public partial class ViewManager
|
||||
{
|
||||
private Control? TryCreateView(ViewModelBase viewModel) =>
|
||||
viewModel switch
|
||||
{
|
||||
MainViewModel => new MainView(),
|
||||
DashboardViewModel => new DashboardView(),
|
||||
AuthSetupViewModel => new AuthSetupView(),
|
||||
DownloadMultipleSetupViewModel => new DownloadMultipleSetupView(),
|
||||
DownloadSingleSetupViewModel => new DownloadSingleSetupView(),
|
||||
MessageBoxViewModel => new MessageBoxView(),
|
||||
SettingsViewModel => new SettingsView(),
|
||||
_ => null
|
||||
};
|
||||
|
||||
public Control? TryBindView(ViewModelBase viewModel)
|
||||
{
|
||||
var name = viewModel
|
||||
.GetType()
|
||||
.FullName?.Replace("ViewModel", "View", StringComparison.Ordinal);
|
||||
|
||||
if (string.IsNullOrWhiteSpace(name))
|
||||
return null;
|
||||
|
||||
var type = Type.GetType(name);
|
||||
if (type is null)
|
||||
return null;
|
||||
|
||||
if (Activator.CreateInstance(type) is not Control view)
|
||||
var view = TryCreateView(viewModel);
|
||||
if (view is null)
|
||||
return null;
|
||||
|
||||
view.DataContext ??= viewModel;
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Text.Json;
|
||||
@ -48,6 +49,8 @@ public partial class SettingsService()
|
||||
|
||||
[ObservableProperty]
|
||||
[property: JsonConverter(typeof(ContainerJsonConverter))]
|
||||
[DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(Container))]
|
||||
[DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(ContainerJsonConverter))]
|
||||
private Container _lastContainer = Container.Mp4;
|
||||
|
||||
[ObservableProperty]
|
||||
|
@ -8,11 +8,8 @@
|
||||
xmlns:materialIcons="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
|
||||
xmlns:materialStyles="clr-namespace:Material.Styles.Controls;assembly=Material.Styles"
|
||||
x:Name="UserControl"
|
||||
x:DataType="components:DashboardViewModel"
|
||||
Loaded="UserControl_OnLoaded">
|
||||
<Design.DataContext>
|
||||
<components:DashboardViewModel />
|
||||
</Design.DataContext>
|
||||
|
||||
<DockPanel>
|
||||
<!-- Header -->
|
||||
<StackPanel
|
||||
@ -315,7 +312,7 @@
|
||||
<Button
|
||||
Padding="4"
|
||||
VerticalAlignment="Center"
|
||||
Command="{Binding $parent[UserControl].DataContext.RestartDownloadCommand}"
|
||||
Command="{Binding $parent[UserControl].((components:DashboardViewModel)DataContext).RestartDownloadCommand}"
|
||||
CommandParameter="{Binding}"
|
||||
IsVisible="{Binding IsCanceledOrFailed}"
|
||||
Theme="{DynamicResource MaterialFlatButton}"
|
||||
|
@ -5,11 +5,8 @@
|
||||
xmlns:dialogs="clr-namespace:YoutubeDownloader.ViewModels.Dialogs"
|
||||
xmlns:materialIcons="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
|
||||
Height="450"
|
||||
MinWidth="450">
|
||||
<Design.DataContext>
|
||||
<dialogs:AuthSetupViewModel />
|
||||
</Design.DataContext>
|
||||
|
||||
MinWidth="450"
|
||||
x:DataType="dialogs:AuthSetupViewModel">
|
||||
<Grid RowDefinitions="Auto,*,Auto">
|
||||
<!-- Title -->
|
||||
<TextBlock
|
||||
|
@ -9,11 +9,8 @@
|
||||
xmlns:materialIcons="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
|
||||
x:Name="UserControl"
|
||||
Width="500"
|
||||
x:DataType="dialogs:DownloadMultipleSetupViewModel"
|
||||
Loaded="UserControl_OnLoaded">
|
||||
<Design.DataContext>
|
||||
<dialogs:DownloadMultipleSetupViewModel />
|
||||
</Design.DataContext>
|
||||
|
||||
<Grid RowDefinitions="Auto,*,Auto,Auto">
|
||||
<!-- Title -->
|
||||
<TextBlock
|
||||
|
@ -9,11 +9,8 @@
|
||||
xmlns:materialIcons="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
|
||||
x:Name="UserControl"
|
||||
Width="500"
|
||||
x:DataType="dialogs:DownloadSingleSetupViewModel"
|
||||
Loaded="UserControl_OnLoaded">
|
||||
<Design.DataContext>
|
||||
<dialogs:DownloadSingleSetupViewModel />
|
||||
</Design.DataContext>
|
||||
|
||||
<Grid RowDefinitions="Auto,*,Auto,Auto">
|
||||
<!-- Info -->
|
||||
<StackPanel
|
||||
|
@ -4,11 +4,8 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:dialogs="clr-namespace:YoutubeDownloader.ViewModels.Dialogs"
|
||||
xmlns:system="clr-namespace:System;assembly=System.Runtime"
|
||||
Width="500">
|
||||
<Design.DataContext>
|
||||
<dialogs:MessageBoxViewModel />
|
||||
</Design.DataContext>
|
||||
|
||||
Width="500"
|
||||
x:DataType="dialogs:MessageBoxViewModel">
|
||||
<Grid RowDefinitions="Auto,*,Auto">
|
||||
<!-- Title -->
|
||||
<TextBlock
|
||||
|
@ -3,11 +3,8 @@
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:dialogs="clr-namespace:YoutubeDownloader.ViewModels.Dialogs"
|
||||
Width="380">
|
||||
<Design.DataContext>
|
||||
<dialogs:SettingsViewModel />
|
||||
</Design.DataContext>
|
||||
|
||||
Width="380"
|
||||
x:DataType="dialogs:SettingsViewModel">
|
||||
<Grid RowDefinitions="Auto,*,Auto">
|
||||
<TextBlock
|
||||
Grid.Row="0"
|
||||
|
@ -10,13 +10,10 @@
|
||||
Height="620"
|
||||
MinWidth="600"
|
||||
MinHeight="400"
|
||||
x:DataType="viewModels:MainViewModel"
|
||||
Icon="/favicon.ico"
|
||||
RenderOptions.BitmapInterpolationMode="HighQuality"
|
||||
WindowStartupLocation="CenterScreen">
|
||||
<Design.DataContext>
|
||||
<viewModels:MainViewModel />
|
||||
</Design.DataContext>
|
||||
|
||||
<!-- Hack: dialog host animations mess up webview positioning, so need to disable them -->
|
||||
<dialogHostAvalonia:DialogHost
|
||||
x:Name="DialogHost"
|
||||
|
@ -4,11 +4,35 @@
|
||||
<OutputType>WinExe</OutputType>
|
||||
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
|
||||
<ApplicationIcon>..\favicon.ico</ApplicationIcon>
|
||||
|
||||
<!-- App manifest is required to embed native windows, namely the WebBrowser control -->
|
||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||
<PublishTrimmed>true</PublishTrimmed>
|
||||
<JsonSerializerIsReflectionEnabledByDefault>true</JsonSerializerIsReflectionEnabledByDefault>
|
||||
<NoWarn>$(NoWarn);IL2104</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- Avalonia-related settings -->
|
||||
<PropertyGroup>
|
||||
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
|
||||
<!-- Warnings not valid when using compiled bindings -->
|
||||
<NoWarn>$(NoWarn);IL2026</NoWarn>
|
||||
<!-- Warnings about Material.Avalonia having peer dependencies -->
|
||||
<NoWarn>$(NoWarn);IL2036</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- Avalonia.WebView is completely incompatible with trimming -->
|
||||
<ItemGroup>
|
||||
<TrimmerRootAssembly Include="Avalonia.WebView" />
|
||||
<TrimmerRootAssembly Include="Avalonia.WebView.Desktop" />
|
||||
<TrimmerRootAssembly Include="Avalonia.WebView.Linux" />
|
||||
<TrimmerRootAssembly Include="Avalonia.WebView.MacCatalyst" />
|
||||
<TrimmerRootAssembly Include="Avalonia.WebView.Windows" />
|
||||
<TrimmerRootAssembly Include="AvaloniaWebView.Shared" />
|
||||
<TrimmerRootAssembly Include="Linux.WebView.Core" />
|
||||
<TrimmerRootAssembly Include="Microsoft.Web.WebView2.Core" />
|
||||
<TrimmerRootAssembly Include="WebView.Avalonia" />
|
||||
<TrimmerRootAssembly Include="WebView.Core" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<AvaloniaResource Include="..\favicon.ico" Link="favicon.ico" />
|
||||
</ItemGroup>
|
||||
@ -52,7 +76,7 @@
|
||||
<FFmpegFileName Condition="$(FFmpegPlatform.StartsWith('win'))">ffmpeg.exe</FFmpegFileName>
|
||||
<FFmpegFileName Condition="'$(FFmpegFileName)' == ''">ffmpeg</FFmpegFileName>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
<Target Name="Download FFmpeg before build" BeforeTargets="PreBuildEvent">
|
||||
<Exec Command="pwsh -ExecutionPolicy Bypass -File "$(ProjectDir)/DownloadFFmpeg.ps1" -Platform $(FFmpegPlatform) -OutputPath "$(ProjectDir)/$(FFmpegFileName)"" LogStandardErrorAsError="true" />
|
||||
<Copy SourceFiles="$(ProjectDir)/$(FFmpegFileName)" DestinationFolder="$(OutDir)" SkipUnchangedFiles="true" />
|
||||
|
Loading…
x
Reference in New Issue
Block a user