aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Installer
diff options
context:
space:
mode:
authorLukePulverenti <luke.pulverenti@gmail.com>2013-02-25 22:43:56 -0500
committerLukePulverenti <luke.pulverenti@gmail.com>2013-02-25 22:43:56 -0500
commitefdb2f3990f6a5250949b7a86bbd83def876f612 (patch)
treed4c7df1c5f159e5a544ebf0b168f18cb302a7712 /MediaBrowser.Installer
parent2d06095447b972c8c7239277428e2c67c8b7ca86 (diff)
parent59ce9444786c4cb3a4eac23f4d26c537a9983c8f (diff)
Merge branch 'master' of https://github.com/MediaBrowser/MediaBrowser
Conflicts: Nuget/MediaBrowser.ApiClient.nuspec
Diffstat (limited to 'MediaBrowser.Installer')
-rw-r--r--MediaBrowser.Installer/App.config4
-rw-r--r--MediaBrowser.Installer/Code/ModelExtensions.cs23
-rw-r--r--MediaBrowser.Installer/Icon.icobin0 -> 140865 bytes
-rw-r--r--MediaBrowser.Installer/MainWindow.xaml.cs73
-rw-r--r--MediaBrowser.Installer/MediaBrowser.Installer.csproj19
-rw-r--r--MediaBrowser.Installer/Properties/app.manifest52
-rw-r--r--MediaBrowser.Installer/mbt.config10
7 files changed, 157 insertions, 24 deletions
diff --git a/MediaBrowser.Installer/App.config b/MediaBrowser.Installer/App.config
index 8e1564635..eb69b68d0 100644
--- a/MediaBrowser.Installer/App.config
+++ b/MediaBrowser.Installer/App.config
@@ -1,5 +1,9 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
+ <appSettings>
+ <add key="product" value="server" />
+ <add key="class" value="Release" />
+ </appSettings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
diff --git a/MediaBrowser.Installer/Code/ModelExtensions.cs b/MediaBrowser.Installer/Code/ModelExtensions.cs
index 5a3051164..66e51ec11 100644
--- a/MediaBrowser.Installer/Code/ModelExtensions.cs
+++ b/MediaBrowser.Installer/Code/ModelExtensions.cs
@@ -1,4 +1,6 @@

+using System.Collections.Generic;
+
namespace MediaBrowser.Installer.Code
{
/// <summary>
@@ -16,5 +18,26 @@ namespace MediaBrowser.Installer.Code
{
return string.IsNullOrEmpty(str) ? def : str;
}
+
+ /// <summary>
+ /// Helper method for Dictionaries since they throw on not-found keys
+ /// </summary>
+ /// <typeparam name="T"></typeparam>
+ /// <typeparam name="U"></typeparam>
+ /// <param name="dictionary">The dictionary.</param>
+ /// <param name="key">The key.</param>
+ /// <param name="defaultValue">The default value.</param>
+ /// <returns>``1.</returns>
+ public static U GetValueOrDefault<T, U>(this Dictionary<T, U> dictionary, T key, U defaultValue)
+ {
+ U val;
+ if (!dictionary.TryGetValue(key, out val))
+ {
+ val = defaultValue;
+ }
+ return val;
+
+ }
+
}
}
diff --git a/MediaBrowser.Installer/Icon.ico b/MediaBrowser.Installer/Icon.ico
new file mode 100644
index 000000000..4acd8f921
--- /dev/null
+++ b/MediaBrowser.Installer/Icon.ico
Binary files differ
diff --git a/MediaBrowser.Installer/MainWindow.xaml.cs b/MediaBrowser.Installer/MainWindow.xaml.cs
index 8924ddb5d..01e15dfd8 100644
--- a/MediaBrowser.Installer/MainWindow.xaml.cs
+++ b/MediaBrowser.Installer/MainWindow.xaml.cs
@@ -1,11 +1,11 @@
using System;
using System.Collections.Generic;
+using System.Configuration;
using System.Diagnostics;
using System.IO;
using System.Net;
using System.Threading.Tasks;
using System.Windows;
-using System.Web;
using System.Linq;
using Ionic.Zip;
using MediaBrowser.Installer.Code;
@@ -20,7 +20,7 @@ namespace MediaBrowser.Installer
public partial class MainWindow : Window
{
protected PackageVersionClass PackageClass = PackageVersionClass.Release;
- protected Version PackageVersion = new Version(10,0,0,0);
+ protected Version PackageVersion = new Version(4,0,0,0);
protected string PackageName = "MBServer";
protected string RootSuffix = "-Server";
protected string TargetExe = "MediaBrowser.ServerApplication.exe";
@@ -65,20 +65,26 @@ namespace MediaBrowser.Installer
protected void GetArgs()
{
- var args = AppDomain.CurrentDomain.SetupInformation.ActivationArguments;
+ var product = ConfigurationManager.AppSettings["product"] ?? "server";
+ PackageClass = (PackageVersionClass) Enum.Parse(typeof (PackageVersionClass), ConfigurationManager.AppSettings["class"] ?? "Release");
- if (args == null || args.ActivationData == null || args.ActivationData.Length <= 0) return;
- var url = new Uri(args.ActivationData[0], UriKind.Absolute);
+ switch (product.ToLower())
+ {
+ case "mbt":
+ PackageName = "MBTheater";
+ RootSuffix = "-UI";
+ TargetExe = "MediaBrowser.UI.exe";
+ FriendlyName = "Media Browser Theater";
+ break;
- var parameters = HttpUtility.ParseQueryString(url.Query);
+ default:
+ PackageName = "MBServer";
+ RootSuffix = "-Server";
+ TargetExe = "MediaBrowser.ServerApplication.exe";
+ FriendlyName = "Media Browser Server";
+ break;
+ }
- // fill in our arguments if there
- PackageName = parameters["package"] ?? "MBServer";
- PackageClass = (PackageVersionClass)Enum.Parse(typeof(PackageVersionClass), parameters["class"] ?? "Release");
- PackageVersion = new Version(parameters["version"].ValueOrDefault("10.0.0.0"));
- RootSuffix = parameters["suffix"] ?? "-Server";
- TargetExe = parameters["target"] ?? "MediaBrowser.ServerApplication.exe";
- FriendlyName = parameters["name"] ?? PackageName;
RootPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "MediaBrowser" + RootSuffix);
}
@@ -89,13 +95,17 @@ namespace MediaBrowser.Installer
/// <returns></returns>
protected async Task DoInstall()
{
- lblStatus.Content = "Downloading "+FriendlyName+"...";
+ lblStatus.Content = string.Format("Downloading {0}...", FriendlyName);
dlAnimation.StartAnimation();
prgProgress.Value = 0;
prgProgress.Visibility = Visibility.Visible;
+ // Determine Package version
+ var version = await GetPackageVersion();
+ lblStatus.Content = string.Format("Downloading {0} (version {1})...", FriendlyName, version.versionStr);
+
// Download
- var archive = await DownloadPackage();
+ var archive = await DownloadPackage(version);
dlAnimation.StopAnimation();
prgProgress.Visibility = btnCancel.Visibility = Visibility.Hidden;
@@ -135,18 +145,14 @@ namespace MediaBrowser.Installer
}
- /// <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()
+ protected async Task<PackageVersionInfo> GetPackageVersion()
{
using (var client = new WebClient())
{
try
{
// 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);
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);
@@ -155,6 +161,27 @@ namespace MediaBrowser.Installer
SystemClose("Could not locate download package. Aborting.");
return null;
}
+ return version;
+ }
+ 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);
// setup download progress and download the package
@@ -210,7 +237,8 @@ namespace MediaBrowser.Installer
product.Save();
var uninstall = (IWshShortcut)shell.CreateShortcut(Path.Combine(startMenu, "Uninstall " + FriendlyName + ".lnk"));
- uninstall.TargetPath = Path.Combine(Path.GetDirectoryName(targetExe),"MediaBrowser.Uninstall.exe "+(PackageName == "MBServer" ? "server" : "mbt"));
+ uninstall.TargetPath = Path.Combine(Path.GetDirectoryName(targetExe),"MediaBrowser.Uninstaller.exe");
+ uninstall.Arguments = (PackageName == "MBServer" ? "server" : "mbt");
uninstall.Description = "Uninstall " + FriendlyName;
uninstall.Save();
@@ -238,5 +266,6 @@ namespace MediaBrowser.Installer
Directory.Delete(location, true);
}
}
+
}
}
diff --git a/MediaBrowser.Installer/MediaBrowser.Installer.csproj b/MediaBrowser.Installer/MediaBrowser.Installer.csproj
index 036340be7..30267e76e 100644
--- a/MediaBrowser.Installer/MediaBrowser.Installer.csproj
+++ b/MediaBrowser.Installer/MediaBrowser.Installer.csproj
@@ -28,8 +28,8 @@
<ProductName>Media Browser Installer</ProductName>
<PublisherName>Media Browser Team</PublisherName>
<SuiteName>Media Browser</SuiteName>
- <TrustUrlParameters>true</TrustUrlParameters>
- <ApplicationRevision>8</ApplicationRevision>
+ <OpenBrowserOnPublish>false</OpenBrowserOnPublish>
+ <ApplicationRevision>14</ApplicationRevision>
<ApplicationVersion>0.1.1.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
@@ -66,6 +66,15 @@
<PropertyGroup>
<SignManifests>true</SignManifests>
</PropertyGroup>
+ <PropertyGroup>
+ <TargetZone>LocalIntranet</TargetZone>
+ </PropertyGroup>
+ <PropertyGroup>
+ <ApplicationManifest>Properties\app.manifest</ApplicationManifest>
+ </PropertyGroup>
+ <PropertyGroup>
+ <ApplicationIcon>Icon.ico</ApplicationIcon>
+ </PropertyGroup>
<ItemGroup>
<Reference Include="Ionic.Zip">
<HintPath>..\packages\DotNetZip.1.9.1.8\lib\net20\Ionic.Zip.dll</HintPath>
@@ -74,6 +83,7 @@
<HintPath>..\packages\ServiceStack.Text.3.9.37\lib\net35\ServiceStack.Text.dll</HintPath>
</Reference>
<Reference Include="System" />
+ <Reference Include="System.Configuration" />
<Reference Include="System.Data" />
<Reference Include="System.Web" />
<Reference Include="System.Xml" />
@@ -139,7 +149,9 @@
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
+ <None Include="mbt.config" />
<None Include="MediaBrowser.Installer_1_TemporaryKey.pfx" />
+ <None Include="Properties\app.manifest" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
@@ -189,6 +201,9 @@
<EmbedInteropTypes>True</EmbedInteropTypes>
</COMReference>
</ItemGroup>
+ <ItemGroup>
+ <Resource Include="Icon.ico" />
+ </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
diff --git a/MediaBrowser.Installer/Properties/app.manifest b/MediaBrowser.Installer/Properties/app.manifest
new file mode 100644
index 000000000..887fa2b9d
--- /dev/null
+++ b/MediaBrowser.Installer/Properties/app.manifest
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="utf-8"?>
+<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <assemblyIdentity version="1.0.0.0" name="MyApplication.app" />
+ <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
+ <security>
+ <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
+ <!-- UAC Manifest Options
+ If you want to change the Windows User Account Control level replace the
+ requestedExecutionLevel node with one of the following.
+
+ <requestedExecutionLevel level="asInvoker" uiAccess="false" />
+ <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
+ <requestedExecutionLevel level="highestAvailable" uiAccess="false" />
+
+ Specifying requestedExecutionLevel node will disable file and registry virtualization.
+ If you want to utilize File and Registry Virtualization for backward
+ compatibility then delete the requestedExecutionLevel node.
+ -->
+ <requestedExecutionLevel level="asInvoker" uiAccess="false" />
+ </requestedPrivileges>
+ <applicationRequestMinimum>
+ <defaultAssemblyRequest permissionSetReference="Custom" />
+ <PermissionSet class="System.Security.PermissionSet" version="1" ID="Custom" SameSite="site" Unrestricted="true" />
+ </applicationRequestMinimum>
+ </security>
+ </trustInfo>
+ <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
+ <application>
+ <!-- A list of all Windows versions that this application is designed to work with.
+ Windows will automatically select the most compatible environment.-->
+ <!-- If your application is designed to work with Windows Vista, uncomment the following supportedOS node-->
+ <!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"></supportedOS>-->
+ <!-- If your application is designed to work with Windows 7, uncomment the following supportedOS node-->
+ <!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>-->
+ <!-- If your application is designed to work with Windows 8, uncomment the following supportedOS node-->
+ <!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"></supportedOS>-->
+ </application>
+ </compatibility>
+ <!-- Enable themes for Windows common controls and dialogs (Windows XP and later) -->
+ <!-- <dependency>
+ <dependentAssembly>
+ <assemblyIdentity
+ type="win32"
+ name="Microsoft.Windows.Common-Controls"
+ version="6.0.0.0"
+ processorArchitecture="*"
+ publicKeyToken="6595b64144ccf1df"
+ language="*"
+ />
+ </dependentAssembly>
+ </dependency>-->
+</asmv1:assembly> \ No newline at end of file
diff --git a/MediaBrowser.Installer/mbt.config b/MediaBrowser.Installer/mbt.config
new file mode 100644
index 000000000..b94d81797
--- /dev/null
+++ b/MediaBrowser.Installer/mbt.config
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<configuration>
+ <appSettings>
+ <add key="product" value="mbt" />
+ <add key="class" value="Release" />
+ </appSettings>
+ <startup>
+ <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
+ </startup>
+</configuration> \ No newline at end of file