Show version number on installer download

pull/702/head
Eric Reed 12 years ago
parent e43f66ef07
commit 1013717808

@ -95,13 +95,17 @@ namespace MediaBrowser.Installer
/// <returns></returns> /// <returns></returns>
protected async Task DoInstall() protected async Task DoInstall()
{ {
lblStatus.Content = "Downloading "+FriendlyName+"..."; lblStatus.Content = string.Format("Downloading {0}...", FriendlyName);
dlAnimation.StartAnimation(); dlAnimation.StartAnimation();
prgProgress.Value = 0; prgProgress.Value = 0;
prgProgress.Visibility = Visibility.Visible; prgProgress.Visibility = Visibility.Visible;
// Determine Package version
var version = await GetPackageVersion().ConfigureAwait(false);
lblStatus.Content = string.Format("Downloading {0} (version {1})...", FriendlyName, version.versionStr);
// Download // Download
var archive = await DownloadPackage(); var archive = await DownloadPackage(version).ConfigureAwait(false);
dlAnimation.StopAnimation(); dlAnimation.StopAnimation();
prgProgress.Visibility = btnCancel.Visibility = Visibility.Hidden; prgProgress.Visibility = btnCancel.Visibility = Visibility.Hidden;
@ -141,18 +145,14 @@ namespace MediaBrowser.Installer
} }
/// <summary> protected async Task<PackageVersionInfo> GetPackageVersion()
/// Download our specified package to an archive in a temp location
/// </summary>
/// <returns>The fully qualified name of the downloaded package</returns>
protected async Task<string> DownloadPackage()
{ {
using (var client = new WebClient()) using (var client = new WebClient())
{ {
try try
{ {
// get the package information for the server // get the package information for the server
var json = await client.DownloadStringTaskAsync("http://www.mb3admin.com/admin/service/package/retrieveAll?name="+PackageName); var json = await client.DownloadStringTaskAsync("http://www.mb3admin.com/admin/service/package/retrieveAll?name=" + PackageName).ConfigureAwait(false);
var packages = JsonSerializer.DeserializeFromString<List<PackageInfo>>(json); 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 <= PackageVersion);
@ -161,11 +161,31 @@ namespace MediaBrowser.Installer
SystemClose("Could not locate download package. Aborting."); SystemClose("Could not locate download package. Aborting.");
return null; return null;
} }
}
catch (Exception e)
{
SystemClose(e.GetType().FullName + "\n\n" + e.Message);
}
}
return null;
}
/// <summary>
/// Download our specified package to an archive in a temp location
/// </summary>
/// <returns>The fully qualified name of the downloaded package</returns>
protected async Task<string> DownloadPackage(PackageVersionInfo version)
{
using (var client = new WebClient())
{
try
{
var archiveFile = Path.Combine(PrepareTempLocation(), version.targetFilename); var archiveFile = Path.Combine(PrepareTempLocation(), version.targetFilename);
// setup download progress and download the package // setup download progress and download the package
client.DownloadProgressChanged += DownloadProgressChanged; client.DownloadProgressChanged += DownloadProgressChanged;
await client.DownloadFileTaskAsync(version.sourceUrl, archiveFile); await client.DownloadFileTaskAsync(version.sourceUrl, archiveFile).ConfigureAwait(false);
return archiveFile; return archiveFile;
} }
catch (Exception e) catch (Exception e)

@ -385,6 +385,8 @@
if $(ConfigurationName) == Release ( if $(ConfigurationName) == Release (
mkdir "$(SolutionDir)..\Deploy\Server\System" mkdir "$(SolutionDir)..\Deploy\Server\System"
xcopy "$(TargetDir)$(TargetFileName)" "$(SolutionDir)..\Deploy\Server\System\" /y xcopy "$(TargetDir)$(TargetFileName)" "$(SolutionDir)..\Deploy\Server\System\" /y
xcopy "$(SolutionDir)Mediabrowser.Uninstaller\bin\Release\MediaBrowser.Uninstaller.exe.config" "$(SolutionDir)..\Deploy\Server\System\" /y
xcopy "$(SolutionDir)Mediabrowser.Uninstaller.Execute\bin\Release\MediaBrowser.Uninstaller.Execute.exe.config" "$(SolutionDir)..\Deploy\Server\System\" /y
xcopy "$(SolutionDir)Mediabrowser.Uninstaller\bin\Release\MediaBrowser.Uninstaller.exe" "$(SolutionDir)..\Deploy\Server\System\" /y xcopy "$(SolutionDir)Mediabrowser.Uninstaller\bin\Release\MediaBrowser.Uninstaller.exe" "$(SolutionDir)..\Deploy\Server\System\" /y
xcopy "$(SolutionDir)Mediabrowser.Uninstaller.Execute\bin\Release\MediaBrowser.Uninstaller.Execute.exe" "$(SolutionDir)..\Deploy\Server\System\" /y xcopy "$(SolutionDir)Mediabrowser.Uninstaller.Execute\bin\Release\MediaBrowser.Uninstaller.Execute.exe" "$(SolutionDir)..\Deploy\Server\System\" /y

@ -34,7 +34,7 @@ namespace MediaBrowser.Uninstaller.Execute
break; break;
default: default:
Console.WriteLine("Please specify which application to un-install (server or mbt)"); MessageBox.Show("Please specify which application to un-install (server or mbt)");
Close(); Close();
break; break;

@ -10,9 +10,9 @@ using System.Windows;
[assembly: AssemblyTitle("MediaBrowser.Uninstaller")] [assembly: AssemblyTitle("MediaBrowser.Uninstaller")]
[assembly: AssemblyDescription("")] [assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Toshiba")] [assembly: AssemblyCompany("Media Browser Team")]
[assembly: AssemblyProduct("MediaBrowser.Uninstaller")] [assembly: AssemblyProduct("MediaBrowser.Uninstaller")]
[assembly: AssemblyCopyright("Copyright © Toshiba 2013")] [assembly: AssemblyCopyright("Copyright © Media Browser Team 2013")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]

@ -31,12 +31,16 @@ namespace MediaBrowser.Uninstaller
var args = Environment.GetCommandLineArgs(); var args = Environment.GetCommandLineArgs();
var product = args.Length > 1 ? args[1] : "server"; var product = args.Length > 1 ? args[1] : "server";
//copy the real program to a temp location so we can delete everything here (including us) //copy the real program to a temp location so we can delete everything here (including us)
var tempExe = Path.Combine(Path.GetTempPath(), "MBUninstall.exe"); var tempExe = Path.Combine(Path.GetTempPath(), "MediaBrowser.Uninstaller.Execute.exe");
var tempConfig = Path.Combine(Path.GetTempPath(), "MediaBrowser.Uninstaller.Execute.exe.config");
using (var file = File.Create(tempExe, 4096, FileOptions.DeleteOnClose)) using (var file = File.Create(tempExe, 4096, FileOptions.DeleteOnClose))
{ {
//copy the real uninstaller to temp location //copy the real uninstaller to temp location
File.WriteAllBytes(tempExe, File.ReadAllBytes(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase) ?? "","MediaBrowser.Uninstaller.Execute.exe"))); var sourceDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase) ?? "";
File.WriteAllBytes(tempExe, File.ReadAllBytes(Path.Combine(sourceDir ,"MediaBrowser.Uninstaller.Execute.exe")));
File.Copy(tempConfig, Path.Combine(sourceDir ,"MediaBrowser.Uninstaller.Execute.exe.config"));
//kick off the copy //kick off the copy
MessageBox.Show("About to start " + tempExe);
Process.Start(tempExe, product); Process.Start(tempExe, product);
//wait for it to start up //wait for it to start up
Thread.Sleep(500); Thread.Sleep(500);

Loading…
Cancel
Save