diff options
Diffstat (limited to 'MediaBrowser.ServerApplication/MainStartup.cs')
| -rw-r--r-- | MediaBrowser.ServerApplication/MainStartup.cs | 126 |
1 files changed, 83 insertions, 43 deletions
diff --git a/MediaBrowser.ServerApplication/MainStartup.cs b/MediaBrowser.ServerApplication/MainStartup.cs index 8e38c9a98..272054609 100644 --- a/MediaBrowser.ServerApplication/MainStartup.cs +++ b/MediaBrowser.ServerApplication/MainStartup.cs @@ -22,6 +22,7 @@ using Emby.Common.Implementations.IO; using Emby.Common.Implementations.Logging; using Emby.Common.Implementations.Networking; using Emby.Common.Implementations.Security; +using Emby.Drawing; using Emby.Server.Core; using Emby.Server.Core.Logging; using Emby.Server.Implementations; @@ -335,8 +336,6 @@ namespace MediaBrowser.ServerApplication var fileSystem = new ManagedFileSystem(logManager.GetLogger("FileSystem"), environmentInfo, appPaths.TempDirectory); - var imageEncoder = ImageEncoderHelper.GetImageEncoder(_logger, logManager, fileSystem, options, () => _appHost.HttpClient, appPaths); - FileSystem = fileSystem; _appHost = new WindowsAppHost(appPaths, @@ -346,7 +345,7 @@ namespace MediaBrowser.ServerApplication new PowerManagement(), "emby.windows.zip", environmentInfo, - imageEncoder, + new NullImageEncoder(), new Server.Startup.Common.SystemEvents(logManager.GetLogger("SystemEvents")), new RecyclableMemoryStreamProvider(), new Networking.NetworkManager(logManager.GetLogger("NetworkManager")), @@ -367,6 +366,19 @@ namespace MediaBrowser.ServerApplication var task = _appHost.Init(initProgress); Task.WaitAll(task); + if (!runService) + { + task = InstallVcredist2013IfNeeded(_appHost, _logger); + Task.WaitAll(task); + + // needed by skia + task = InstallVcredist2015IfNeeded(_appHost, _logger); + Task.WaitAll(task); + } + + // set image encoder here + _appHost.ImageProcessor.ImageEncoder = ImageEncoderHelper.GetImageEncoder(_logger, logManager, fileSystem, options, () => _appHost.HttpClient, appPaths); + task = task.ContinueWith(new Action<Task>(a => _appHost.RunStartupTasks()), TaskContinuationOptions.OnlyOnRanToCompletion | TaskContinuationOptions.AttachedToParent); if (runService) @@ -377,9 +389,6 @@ namespace MediaBrowser.ServerApplication { Task.WaitAll(task); - task = InstallVcredist2013IfNeeded(_appHost, _logger); - Task.WaitAll(task); - Microsoft.Win32.SystemEvents.SessionSwitch += SystemEvents_SessionSwitch; HideSplashScreen(); @@ -736,32 +745,61 @@ namespace MediaBrowser.ServerApplication Process.Start(startInfo); } - private static bool CanRestartWindowsService() + private static async Task InstallVcredist2013IfNeeded(ApplicationHost appHost, ILogger logger) { - var startInfo = new ProcessStartInfo - { - FileName = "cmd.exe", - CreateNoWindow = true, - WindowStyle = ProcessWindowStyle.Hidden, - Verb = "runas", - ErrorDialog = false, - Arguments = String.Format("/c sc query {0}", BackgroundService.GetExistingServiceName()) - }; - using (var process = Process.Start(startInfo)) + // Reference + // http://stackoverflow.com/questions/12206314/detect-if-visual-c-redistributable-for-visual-studio-2012-is-installed + + try { - process.WaitForExit(); - if (process.ExitCode == 0) - { - return true; - } - else + var subkey = Environment.Is64BitProcess + ? "SOFTWARE\\WOW6432Node\\Microsoft\\VisualStudio\\12.0\\VC\\Runtimes\\x64" + : "SOFTWARE\\Microsoft\\VisualStudio\\12.0\\VC\\Runtimes\\x86"; + + using (RegistryKey ndpKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Default) + .OpenSubKey(subkey)) { - return false; + if (ndpKey != null && ndpKey.GetValue("Version") != null) + { + var installedVersion = ((string)ndpKey.GetValue("Version")).TrimStart('v'); + if (installedVersion.StartsWith("12", StringComparison.OrdinalIgnoreCase)) + { + return; + } + } } } + catch (Exception ex) + { + logger.ErrorException("Error getting .NET Framework version", ex); + return; + } + + MessageBox.Show("The Visual C++ 2013 Runtime will now be installed.", "Install Visual C++ Runtime", MessageBoxButtons.OK, MessageBoxIcon.Information); + + try + { + await InstallVcredist(GetVcredist2013Url()).ConfigureAwait(false); + } + catch (Exception ex) + { + logger.ErrorException("Error installing Visual Studio C++ runtime", ex); + } } - private static async Task InstallVcredist2013IfNeeded(ApplicationHost appHost, ILogger logger) + private static string GetVcredist2013Url() + { + 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"; + } + + private static async Task InstallVcredist2015IfNeeded(ApplicationHost appHost, ILogger logger) { // Reference // http://stackoverflow.com/questions/12206314/detect-if-visual-c-redistributable-for-visual-studio-2012-is-installed @@ -769,8 +807,8 @@ namespace MediaBrowser.ServerApplication try { var subkey = Environment.Is64BitProcess - ? "SOFTWARE\\WOW6432Node\\Microsoft\\VisualStudio\\12.0\\VC\\Runtimes\\x64" - : "SOFTWARE\\Microsoft\\VisualStudio\\12.0\\VC\\Runtimes\\x86"; + ? "SOFTWARE\\WOW6432Node\\Microsoft\\VisualStudio\\14.0\\VC\\Runtimes\\x64" + : "SOFTWARE\\Microsoft\\VisualStudio\\14.0\\VC\\Runtimes\\x86"; using (RegistryKey ndpKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Default) .OpenSubKey(subkey)) @@ -778,7 +816,7 @@ namespace MediaBrowser.ServerApplication if (ndpKey != null && ndpKey.GetValue("Version") != null) { var installedVersion = ((string)ndpKey.GetValue("Version")).TrimStart('v'); - if (installedVersion.StartsWith("12", StringComparison.OrdinalIgnoreCase)) + if (installedVersion.StartsWith("14", StringComparison.OrdinalIgnoreCase)) { return; } @@ -791,9 +829,11 @@ namespace MediaBrowser.ServerApplication return; } + MessageBox.Show("The Visual C++ 2015 Runtime will now be installed.", "Install Visual C++ Runtime", MessageBoxButtons.OK, MessageBoxIcon.Information); + try { - await InstallVcredist2013().ConfigureAwait(false); + await InstallVcredist(GetVcredist2015Url()).ConfigureAwait(false); } catch (Exception ex) { @@ -801,13 +841,25 @@ namespace MediaBrowser.ServerApplication } } - private async static Task InstallVcredist2013() + private static string GetVcredist2015Url() + { + if (Environment.Is64BitProcess) + { + return "https://github.com/MediaBrowser/Emby.Resources/raw/master/vcredist2015/vc_redist.x64.exe"; + } + + // TODO: ARM url - https://github.com/MediaBrowser/Emby.Resources/raw/master/vcredist2015/vcredist_arm.exe + + return "https://github.com/MediaBrowser/Emby.Resources/raw/master/vcredist2015/vc_redist.x86.exe"; + } + + private async static Task InstallVcredist(string url) { var httpClient = _appHost.HttpClient; var tmp = await httpClient.GetTempFile(new HttpRequestOptions { - Url = GetVcredist2013Url(), + Url = url, Progress = new Progress<double>() }).ConfigureAwait(false); @@ -833,18 +885,6 @@ namespace MediaBrowser.ServerApplication } } - private static string GetVcredist2013Url() - { - 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> |
