The Free Software Media System - Server Backend & API
auto install vcredist
Luke Pulverenti30229982bab7
diff --git a/Emby.Drawing/ImageMagick/ImageMagickEncoder.cs b/Emby.Drawing/ImageMagick/ImageMagickEncoder.csindex 5ca6748881..12a98edffa 100644--- a/Emby.Drawing/ImageMagick/ImageMagickEncoder.cs+++ b/Emby.Drawing/ImageMagick/ImageMagickEncoder.cs@@ -72,11 +72,16 @@ namespace Emby.Drawing.ImageMagickprivate void LogVersion(){- _logger.Info("ImageMagick version: " + Wand.VersionString);+ _logger.Info("ImageMagick version: " + GetVersion());TestWebp();Wand.SetMagickThreadCount(1);}+ public static string GetVersion()+ {+ return Wand.VersionString;+ }+private bool _webpAvailable = true;private void TestWebp(){diff --git a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs b/MediaBrowser.Common.Implementations/BaseApplicationHost.csindex 6dc97100db..2a93efcdeb 100644--- a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs+++ b/MediaBrowser.Common.Implementations/BaseApplicationHost.cs@@ -133,7 +133,7 @@ namespace MediaBrowser.Common.Implementations/// Gets the HTTP client./// </summary>/// <value>The HTTP client.</value>- protected IHttpClient HttpClient { get; private set; }+ public IHttpClient HttpClient { get; private set; }/// <summary>/// Gets the network manager./// </summary>diff --git a/MediaBrowser.ServerApplication/MainStartup.cs b/MediaBrowser.ServerApplication/MainStartup.csindex 69b78e02bc..ac6fd1bbea 100644--- a/MediaBrowser.ServerApplication/MainStartup.cs+++ b/MediaBrowser.ServerApplication/MainStartup.cs@@ -18,7 +18,9 @@ using System.Threading;using System.Threading.Tasks;using System.Windows.Forms;using CommonIO.Windows;+using Emby.Drawing.ImageMagick;using ImageMagickSharp;+using MediaBrowser.Common.Net;using MediaBrowser.Server.Implementations.Logging;namespace MediaBrowser.ServerApplication@@ -251,6 +253,9 @@ namespace MediaBrowser.ServerApplication{Task.WaitAll(task);+ task = InstallVcredistIfNeeded(_appHost, _logger);+ Task.WaitAll(task);+SystemEvents.SessionEnding += SystemEvents_SessionEnding;SystemEvents.SessionSwitch += SystemEvents_SessionSwitch;@@ -568,6 +573,70 @@ namespace MediaBrowser.ServerApplication}}+ private static async Task InstallVcredistIfNeeded(ApplicationHost appHost, ILogger logger)+ {+ try+ {+ var version = ImageMagickEncoder.GetVersion();+ return;+ }+ catch (Exception ex)+ {+ logger.ErrorException("Error loading ImageMagick", ex);+ }++ try+ {+ await InstallVcredist().ConfigureAwait(false);+ }+ catch (Exception ex)+ {+ logger.ErrorException("Error installing ImageMagick", ex);+ }+ }++ private async static Task InstallVcredist()+ {+ var httpClient = _appHost.HttpClient;++ var tmp = await httpClient.GetTempFile(new HttpRequestOptions+ {+ Url = GetVcredistUrl(),+ Progress = new Progress<double>()++ }).ConfigureAwait(false);++ var exePath = Path.ChangeExtension(tmp, ".exe");+ File.Copy(tmp, exePath);++ var startInfo = new ProcessStartInfo+ {+ FileName = exePath,++ CreateNoWindow = true,+ WindowStyle = ProcessWindowStyle.Hidden,+ Verb = "runas",+ ErrorDialog = false+ };++ using (var process = Process.Start(startInfo))+ {+ process.WaitForExit();+ }+ }++ private static string GetVcredistUrl()+ {+ if (Environment.Is64BitProcess)+ {+ return "https://github.com/MediaBrowser/Emby.Resources/raw/master/vcredist2013/vcredist_x64.exe";+ }++ // TODO: ARM url - https://github.com/MediaBrowser/Emby.Resources/raw/master/vcredist2013/vcredist_arm.exe++ return "https://github.com/MediaBrowser/Emby.Resources/raw/master/vcredist2013/vcredist_x86.exe";+ }+/// <summary>/// Sets the error mode./// </summary>diff --git a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csprojindex ddae4ee5a7..e8d5b6d27e 100644--- a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj+++ b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj@@ -1055,6 +1055,10 @@<Content Include="Resources\Images\mb3logo800.png" /></ItemGroup><ItemGroup>+ <ProjectReference Include="..\Emby.Drawing\Emby.Drawing.csproj">+ <Project>{08fff49b-f175-4807-a2b5-73b0ebd9f716}</Project>+ <Name>Emby.Drawing</Name>+ </ProjectReference><ProjectReference Include="..\MediaBrowser.Api\MediaBrowser.Api.csproj"><Project>{4fd51ac5-2c16-4308-a993-c3a84f3b4582}</Project><Name>MediaBrowser.Api</Name>