mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Merge pull request #2179 from wabbajack-tools/install-webview
Install WebView2 after updating Wabbajack
This commit is contained in:
commit
e130f381c6
@ -24,7 +24,6 @@ using Wabbajack.Paths.IO;
|
|||||||
using Wabbajack.Services.OSIntegrated;
|
using Wabbajack.Services.OSIntegrated;
|
||||||
using Wabbajack.UserIntervention;
|
using Wabbajack.UserIntervention;
|
||||||
using Wabbajack.Util;
|
using Wabbajack.Util;
|
||||||
using WebView2.Runtime.AutoInstaller;
|
|
||||||
using Ext = Wabbajack.Common.Ext;
|
using Ext = Wabbajack.Common.Ext;
|
||||||
|
|
||||||
namespace Wabbajack
|
namespace Wabbajack
|
||||||
@ -51,8 +50,6 @@ namespace Wabbajack
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
WebView2AutoInstaller.CheckAndInstallAsync(false, false).Wait();
|
|
||||||
|
|
||||||
RxApp.MainThreadScheduler = new DispatcherScheduler(Dispatcher.CurrentDispatcher);
|
RxApp.MainThreadScheduler = new DispatcherScheduler(Dispatcher.CurrentDispatcher);
|
||||||
_host = Host.CreateDefaultBuilder(Array.Empty<string>())
|
_host = Host.CreateDefaultBuilder(Array.Empty<string>())
|
||||||
.ConfigureLogging(AddLogging)
|
.ConfigureLogging(AddLogging)
|
||||||
|
@ -100,7 +100,6 @@
|
|||||||
<PackageReference Include="ReactiveUI.WPF" Version="18.3.1" />
|
<PackageReference Include="ReactiveUI.WPF" Version="18.3.1" />
|
||||||
<PackageReference Include="Silk.NET.DXGI" Version="2.16.0" />
|
<PackageReference Include="Silk.NET.DXGI" Version="2.16.0" />
|
||||||
<PackageReference Include="System.Reactive" Version="5.0.0" />
|
<PackageReference Include="System.Reactive" Version="5.0.0" />
|
||||||
<PackageReference Include="WebView2.Runtime.AutoInstaller" Version="1.0.0" />
|
|
||||||
<PackageReference Include="WPFThemes.DarkBlend" Version="1.0.8" />
|
<PackageReference Include="WPFThemes.DarkBlend" Version="1.0.8" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
@ -9,8 +9,10 @@ using System.Text.Json;
|
|||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using JetBrains.Annotations;
|
||||||
using MessageBox.Avalonia.DTO;
|
using MessageBox.Avalonia.DTO;
|
||||||
using ReactiveUI.Fody.Helpers;
|
using ReactiveUI.Fody.Helpers;
|
||||||
|
using Wabbajack.Common;
|
||||||
using Wabbajack.Compression.Zip;
|
using Wabbajack.Compression.Zip;
|
||||||
using Wabbajack.Downloaders.Http;
|
using Wabbajack.Downloaders.Http;
|
||||||
using Wabbajack.DTOs;
|
using Wabbajack.DTOs;
|
||||||
@ -122,7 +124,7 @@ public class MainWindowViewModel : ViewModelBase
|
|||||||
|
|
||||||
|
|
||||||
var wc = new WebClient();
|
var wc = new WebClient();
|
||||||
wc.DownloadProgressChanged += UpdateProgress;
|
wc.DownloadProgressChanged += (sender, args) => UpdateProgress($"{_version.Version}", sender, args);
|
||||||
Status = $"Downloading {_version.Version} ...";
|
Status = $"Downloading {_version.Version} ...";
|
||||||
byte[] data;
|
byte[] data;
|
||||||
try
|
try
|
||||||
@ -166,10 +168,53 @@ public class MainWindowViewModel : ViewModelBase
|
|||||||
{
|
{
|
||||||
_errors.Add(ex.Message);
|
_errors.Add(ex.Message);
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
|
try
|
||||||
{
|
{
|
||||||
|
await InstallWebView();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
_errors.Add(e.Message);
|
||||||
|
}
|
||||||
|
|
||||||
await FinishAndExit();
|
await FinishAndExit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[UriString]
|
||||||
|
private const string WebViewDownloadLink = "https://go.microsoft.com/fwlink/p/?LinkId=2124703";
|
||||||
|
|
||||||
|
private async Task InstallWebView(CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
var setupPath = KnownFolders.WabbajackAppLocal.Combine("MicrosoftEdgeWebview2Setup.exe");
|
||||||
|
if (setupPath.FileExists()) return;
|
||||||
|
|
||||||
|
var wc = new WebClient();
|
||||||
|
wc.DownloadProgressChanged += (sender, args) => UpdateProgress("WebView2", sender, args);
|
||||||
|
|
||||||
|
Status = "Downloading WebView2 Runtime";
|
||||||
|
|
||||||
|
byte[] data;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
data = await wc.DownloadDataTaskAsync(WebViewDownloadLink);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_errors.Add(ex.Message);
|
||||||
|
await FinishAndExit();
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
|
||||||
|
await setupPath.WriteAllBytesAsync(new Memory<byte>(data), cancellationToken);
|
||||||
|
|
||||||
|
var process = new ProcessHelper
|
||||||
|
{
|
||||||
|
Path = setupPath,
|
||||||
|
Arguments = new []{"/silent /install"}
|
||||||
|
};
|
||||||
|
|
||||||
|
await process.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task VerifyCurrentLocation()
|
private async Task VerifyCurrentLocation()
|
||||||
@ -211,6 +256,7 @@ public class MainWindowViewModel : ViewModelBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[ContractAnnotation("=> halt")]
|
||||||
private async Task FinishAndExit()
|
private async Task FinishAndExit()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -275,9 +321,9 @@ public class MainWindowViewModel : ViewModelBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateProgress(object sender, DownloadProgressChangedEventArgs e)
|
private void UpdateProgress(string what, object sender, DownloadProgressChangedEventArgs e)
|
||||||
{
|
{
|
||||||
Status = $"Downloading {_version.Version} ({e.ProgressPercentage}%)...";
|
Status = $"Downloading {what} ({e.ProgressPercentage}%)...";
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<(Version Version, long Size, Func<Task<Uri>> Uri)> GetGithubRelease(CancellationToken token)
|
private async Task<(Version Version, long Size, Func<Task<Uri>> Uri)> GetGithubRelease(CancellationToken token)
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
<PackageReference Include="Avalonia.Desktop" Version="11.0.0-preview4" />
|
<PackageReference Include="Avalonia.Desktop" Version="11.0.0-preview4" />
|
||||||
<PackageReference Include="Avalonia.Diagnostics" Version="11.0.0-preview4" />
|
<PackageReference Include="Avalonia.Diagnostics" Version="11.0.0-preview4" />
|
||||||
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.0-preview4" />
|
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.0-preview4" />
|
||||||
|
<PackageReference Include="JetBrains.Annotations" Version="2022.1.0" />
|
||||||
<PackageReference Include="MessageBox.Avalonia" Version="2.3.1-prev2" />
|
<PackageReference Include="MessageBox.Avalonia" Version="2.3.1-prev2" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.2-mauipre.1.22102.15" />
|
<PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.2-mauipre.1.22102.15" />
|
||||||
<PackageReference Include="ReactiveUI.Fody" Version="18.3.1" />
|
<PackageReference Include="ReactiveUI.Fody" Version="18.3.1" />
|
||||||
|
Loading…
Reference in New Issue
Block a user