auto install vcredist

pull/702/head
Luke Pulverenti 9 years ago
parent 8ec08ef310
commit 30229982ba

@ -72,11 +72,16 @@ namespace Emby.Drawing.ImageMagick
private 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()
{

@ -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>

@ -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>

@ -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>

Loading…
Cancel
Save