aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukePulverenti <luke.pulverenti@gmail.com>2013-03-11 12:55:00 -0400
committerLukePulverenti <luke.pulverenti@gmail.com>2013-03-11 12:55:00 -0400
commit61b5f66f20f1e62c09442c0758c55f6a630526db (patch)
treea678c851c2a5b24582e52641092d11f5068bb233
parentfe91772f18dada23d9f1b28d3816a30d0f21448b (diff)
parentf8261ebdb5be9ff6c69ee88a0303f4d09846b307 (diff)
Merge branch 'master' of https://github.com/MediaBrowser/MediaBrowser
-rw-r--r--MediaBrowser.Common.Implementations/Updates/ApplicationUpdater.cs2
-rw-r--r--MediaBrowser.Installer/MainWindow.xaml.cs74
-rw-r--r--MediaBrowser.Installer/MediaBrowser.Installer.csproj2
-rw-r--r--MediaBrowser.Uninstaller.Execute/MainWindow.xaml.cs34
-rw-r--r--MediaBrowser.Uninstaller/MediaBrowser.Uninstaller.csproj5
5 files changed, 107 insertions, 10 deletions
diff --git a/MediaBrowser.Common.Implementations/Updates/ApplicationUpdater.cs b/MediaBrowser.Common.Implementations/Updates/ApplicationUpdater.cs
index 3b06f2006..00e232e44 100644
--- a/MediaBrowser.Common.Implementations/Updates/ApplicationUpdater.cs
+++ b/MediaBrowser.Common.Implementations/Updates/ApplicationUpdater.cs
@@ -24,7 +24,7 @@ namespace MediaBrowser.Common.Implementations.Updates
var target = Path.Combine(Path.GetTempPath(), UpdaterExe);
var product = app == MBApplication.MBTheater ? "mbt" : "server";
File.Copy(source, target, true);
- Process.Start(UpdaterExe, string.Format("product={0} archive=\"{1}\" caller={2}", product, archive, Process.GetCurrentProcess().Id));
+ Process.Start(target, string.Format("product={0} archive=\"{1}\" caller={2}", product, archive, Process.GetCurrentProcess().Id));
// That's it. The installer will do the work once we exit
}
diff --git a/MediaBrowser.Installer/MainWindow.xaml.cs b/MediaBrowser.Installer/MainWindow.xaml.cs
index 431a7fb58..c8e1dc97c 100644
--- a/MediaBrowser.Installer/MainWindow.xaml.cs
+++ b/MediaBrowser.Installer/MainWindow.xaml.cs
@@ -9,6 +9,7 @@ using System.Windows;
using System.Linq;
using Ionic.Zip;
using MediaBrowser.Installer.Code;
+using Microsoft.Win32;
using ServiceStack.Text;
namespace MediaBrowser.Installer
@@ -19,7 +20,8 @@ namespace MediaBrowser.Installer
public partial class MainWindow : Window
{
protected PackageVersionClass PackageClass = PackageVersionClass.Release;
- protected Version PackageVersion = new Version(4,0,0,0);
+ protected Version RequestedVersion = new Version(4,0,0,0);
+ protected Version ActualVersion;
protected string PackageName = "MBServer";
protected string RootSuffix = "-Server";
protected string TargetExe = "MediaBrowser.ServerApplication.exe";
@@ -92,7 +94,7 @@ namespace MediaBrowser.Installer
var product = args.GetValueOrDefault("product", null) ?? ConfigurationManager.AppSettings["product"] ?? "server";
PackageClass = (PackageVersionClass) Enum.Parse(typeof (PackageVersionClass), args.GetValueOrDefault("class", null) ?? ConfigurationManager.AppSettings["class"] ?? "Release");
- PackageVersion = new Version(args.GetValueOrDefault("version", "4.0"));
+ RequestedVersion = new Version(args.GetValueOrDefault("version", "4.0"));
var callerId = args.GetValueOrDefault("caller", null);
if (callerId != null)
@@ -140,6 +142,7 @@ namespace MediaBrowser.Installer
// Determine Package version
var version = await GetPackageVersion();
+ ActualVersion = version.version;
// Now try and shut down the server if that is what we are installing and it is running
var procs = Process.GetProcessesByName("mediabrowser.serverapplication");
@@ -202,6 +205,7 @@ namespace MediaBrowser.Installer
catch (Exception e)
{
SystemClose("Error Downloading Package - " + e.GetType().FullName + "\n\n" + e.Message);
+ return;
}
}
@@ -224,11 +228,13 @@ namespace MediaBrowser.Installer
{
SystemClose("Error Removing Archive - " + e.GetType().FullName + "\n\n" + e.Message);
+ return;
}
}
catch (Exception e)
{
SystemClose("Error Extracting - " + e.GetType().FullName + "\n\n" + e.Message);
+ return;
}
// Create shortcut
@@ -240,6 +246,7 @@ namespace MediaBrowser.Installer
catch (Exception e)
{
SystemClose("Error Creating Shortcut - "+e.GetType().FullName+"\n\n"+e.Message);
+ return;
}
// And run
@@ -250,6 +257,7 @@ namespace MediaBrowser.Installer
catch (Exception e)
{
SystemClose("Error Executing - "+fullPath+ " "+e.GetType().FullName+"\n\n"+e.Message);
+ return;
}
SystemClose();
@@ -264,7 +272,7 @@ namespace MediaBrowser.Installer
var json = await MainClient.DownloadStringTaskAsync("http://www.mb3admin.com/admin/service/package/retrieveAll?name=" + PackageName);
var packages = JsonSerializer.DeserializeFromString<List<PackageInfo>>(json);
- var version = packages[0].versions.Where(v => v.classification <= PackageClass).OrderByDescending(v => v.version).FirstOrDefault(v => v.version <= PackageVersion);
+ var version = packages[0].versions.Where(v => v.classification <= PackageClass).OrderByDescending(v => v.version).FirstOrDefault(v => v.version <= RequestedVersion);
if (version == null)
{
SystemClose("Could not locate download package. Aborting.");
@@ -373,13 +381,67 @@ namespace MediaBrowser.Installer
dashboard.Save();
}
- var uninstall = new ShellShortcut(Path.Combine(startMenu, "Uninstall " + FriendlyName + ".lnk"))
- {Path = Path.Combine(Path.GetDirectoryName(targetExe), "MediaBrowser.Uninstaller.exe"), Arguments = (PackageName == "MBServer" ? "server" : "mbt"), Description = "Uninstall " + FriendlyName};
- uninstall.Save();
+ CreateUninstaller(Path.Combine(Path.GetDirectoryName(targetExe) ?? "", "MediaBrowser.Uninstaller.exe")+ " "+ (PackageName == "MBServer" ? "server" : "mbt"), targetExe);
}
/// <summary>
+ /// Create uninstall entry in add/remove
+ /// </summary>
+ /// <param name="uninstallPath"></param>
+ /// <param name="targetExe"></param>
+ private void CreateUninstaller(string uninstallPath, string targetExe)
+ {
+ using (var parent = Registry.LocalMachine.OpenSubKey(
+ @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall", true))
+ {
+ if (parent == null)
+ {
+ MessageBox.Show("Uninstall registry key not found.");
+ return;
+ }
+ try
+ {
+ RegistryKey key = null;
+
+ try
+ {
+ const string guidText = "{4E76DB4E-1BB9-4A7B-860C-7940779CF7A0}";
+ key = parent.OpenSubKey(guidText, true) ??
+ parent.CreateSubKey(guidText);
+
+ if (key == null)
+ {
+ MessageBox.Show(String.Format("Unable to create uninstaller entry'{0}\\{1}'", @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall", guidText));
+ return;
+ }
+
+ key.SetValue("DisplayName", FriendlyName);
+ key.SetValue("ApplicationVersion", ActualVersion);
+ key.SetValue("Publisher", "Media Browser Team");
+ key.SetValue("DisplayIcon", targetExe);
+ key.SetValue("DisplayVersion", ActualVersion.ToString(2));
+ key.SetValue("URLInfoAbout", "http://www.mediabrowser3.com");
+ key.SetValue("Contact", "http://community.mediabrowser.tv");
+ key.SetValue("InstallDate", DateTime.Now.ToString("yyyyMMdd"));
+ key.SetValue("UninstallString", uninstallPath);
+ }
+ finally
+ {
+ if (key != null)
+ {
+ key.Close();
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show("An error occurred writing uninstall information to the registry.");
+ }
+ }
+ }
+
+ /// <summary>
/// Prepare a temporary location to download to
/// </summary>
/// <returns>The path to the temporary location</returns>
diff --git a/MediaBrowser.Installer/MediaBrowser.Installer.csproj b/MediaBrowser.Installer/MediaBrowser.Installer.csproj
index 470a18463..819b17c50 100644
--- a/MediaBrowser.Installer/MediaBrowser.Installer.csproj
+++ b/MediaBrowser.Installer/MediaBrowser.Installer.csproj
@@ -31,7 +31,7 @@
<PublisherName>Media Browser Team</PublisherName>
<SuiteName>Media Browser</SuiteName>
<OpenBrowserOnPublish>false</OpenBrowserOnPublish>
- <ApplicationRevision>36</ApplicationRevision>
+ <ApplicationRevision>38</ApplicationRevision>
<ApplicationVersion>0.1.1.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
diff --git a/MediaBrowser.Uninstaller.Execute/MainWindow.xaml.cs b/MediaBrowser.Uninstaller.Execute/MainWindow.xaml.cs
index 4e2e80787..7b1983d53 100644
--- a/MediaBrowser.Uninstaller.Execute/MainWindow.xaml.cs
+++ b/MediaBrowser.Uninstaller.Execute/MainWindow.xaml.cs
@@ -1,7 +1,7 @@
using System;
using System.Diagnostics;
using System.Net;
-using System.Reflection;
+using Microsoft.Win32;
using System.IO;
using System.Threading;
using System.Windows;
@@ -195,13 +195,43 @@ namespace MediaBrowser.Uninstaller.Execute
}
}
+ // Remove reference to us
+ RemoveUninstall();
+
// and done
lblHeading.Content = string.Format("Media Browser {0} Uninstalled.", Product);
btnUninstall.Visibility = Visibility.Hidden;
btnFinished.Visibility = Visibility.Visible;
}
- private static void RemoveShortcut(string path)
+ private void RemoveUninstall()
+ {
+
+ using (var parent = Registry.LocalMachine.OpenSubKey(
+ @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall", true))
+ {
+ if (parent == null)
+ {
+ MessageBox.Show("Uninstall registry key not found.");
+ return;
+ }
+ try
+ {
+ const string guidText = "{4E76DB4E-1BB9-4A7B-860C-7940779CF7A0}";
+ parent.DeleteSubKey(guidText,false);
+
+ }
+ catch (Exception ex)
+ {
+ throw new Exception(
+ "An error occurred removing uninstall information from the registry.",
+ ex);
+ }
+ }
+ }
+
+ private static
+ void RemoveShortcut(string path)
{
try
{
diff --git a/MediaBrowser.Uninstaller/MediaBrowser.Uninstaller.csproj b/MediaBrowser.Uninstaller/MediaBrowser.Uninstaller.csproj
index 3291ebdb1..cdfec10d1 100644
--- a/MediaBrowser.Uninstaller/MediaBrowser.Uninstaller.csproj
+++ b/MediaBrowser.Uninstaller/MediaBrowser.Uninstaller.csproj
@@ -34,6 +34,11 @@
<PropertyGroup>
<StartupObject />
</PropertyGroup>
+ <PropertyGroup>
+ <ApplicationIcon>
+ </ApplicationIcon>
+ </PropertyGroup>
+ <PropertyGroup />
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />