install 2015 vcredist
This commit is contained in:
parent
6fd86f61cb
commit
260f2da0a1
|
@ -380,6 +380,9 @@ namespace MediaBrowser.ServerApplication
|
|||
task = InstallVcredist2013IfNeeded(_appHost, _logger);
|
||||
Task.WaitAll(task);
|
||||
|
||||
task = InstallVcredist2015IfNeeded(_appHost, _logger);
|
||||
Task.WaitAll(task);
|
||||
|
||||
Microsoft.Win32.SystemEvents.SessionSwitch += SystemEvents_SessionSwitch;
|
||||
|
||||
HideSplashScreen();
|
||||
|
@ -736,31 +739,6 @@ namespace MediaBrowser.ServerApplication
|
|||
Process.Start(startInfo);
|
||||
}
|
||||
|
||||
private static bool CanRestartWindowsService()
|
||||
{
|
||||
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))
|
||||
{
|
||||
process.WaitForExit();
|
||||
if (process.ExitCode == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static async Task InstallVcredist2013IfNeeded(ApplicationHost appHost, ILogger logger)
|
||||
{
|
||||
// Reference
|
||||
|
@ -791,9 +769,11 @@ namespace MediaBrowser.ServerApplication
|
|||
return;
|
||||
}
|
||||
|
||||
MessageBox.Show("The Visual C++ 2013 Runtime will now be installed.");
|
||||
|
||||
try
|
||||
{
|
||||
await InstallVcredist2013().ConfigureAwait(false);
|
||||
await InstallVcredist(GetVcredist2013Url()).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -801,13 +781,79 @@ namespace MediaBrowser.ServerApplication
|
|||
}
|
||||
}
|
||||
|
||||
private async static Task InstallVcredist2013()
|
||||
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
|
||||
|
||||
try
|
||||
{
|
||||
var subkey = Environment.Is64BitProcess
|
||||
? "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))
|
||||
{
|
||||
if (ndpKey != null && ndpKey.GetValue("Version") != null)
|
||||
{
|
||||
var installedVersion = ((string)ndpKey.GetValue("Version")).TrimStart('v');
|
||||
if (installedVersion.StartsWith("14", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.ErrorException("Error getting .NET Framework version", ex);
|
||||
return;
|
||||
}
|
||||
|
||||
MessageBox.Show("The Visual C++ 2015 Runtime will now be installed.");
|
||||
|
||||
try
|
||||
{
|
||||
await InstallVcredist(GetVcredist2015Url()).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.ErrorException("Error installing Visual Studio C++ runtime", ex);
|
||||
}
|
||||
}
|
||||
|
||||
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 +879,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>
|
||||
|
|
Loading…
Reference in New Issue
Block a user