diff --git a/Application/FeedCenter.csproj b/Application/FeedCenter.csproj
index 3fe72a3..c8638eb 100644
--- a/Application/FeedCenter.csproj
+++ b/Application/FeedCenter.csproj
@@ -179,7 +179,6 @@
True
..\packages\Microsoft.SqlServer.Compact.4.0.8854.1\lib\net40\System.Data.SqlServerCe.Entity.dll
-
@@ -188,6 +187,7 @@
4.0
+
@@ -271,6 +271,8 @@
SplashWindow.xaml
+
+
Designer
diff --git a/Application/MainWindow.xaml.cs b/Application/MainWindow.xaml.cs
index a154fe9..02b02ba 100644
--- a/Application/MainWindow.xaml.cs
+++ b/Application/MainWindow.xaml.cs
@@ -7,7 +7,6 @@ using FeedCenter.Properties;
using System;
using System.Collections.Generic;
using System.ComponentModel;
-using System.Deployment.Application;
using System.IO;
using System.Linq;
using System.Threading;
@@ -17,6 +16,7 @@ using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Interop;
using System.Windows.Media;
+using FeedCenter.Update;
namespace FeedCenter
{
@@ -98,6 +98,10 @@ namespace FeedCenter
// Initialize the feed display
InitializeFeed();
+ // Check for update
+ if (UpdateCheck.UpdateAvailable)
+ newVersionLink.Visibility = Visibility.Visible;
+
Tracer.WriteLine("MainForm creation finished");
}
@@ -539,11 +543,6 @@ namespace FeedCenter
public Feed Feed;
}
- private class FeedReadWorkerOutput
- {
- public UpdateCheckInfo UpdateResult;
- }
-
private void SetProgressMode(bool value, int feedCount)
{
// Reset the progress bar if we need it
@@ -607,9 +606,6 @@ namespace FeedCenter
private void HandleFeedReadWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
- // Get the state info
- var workerOutput = (FeedReadWorkerOutput) e.Result;
-
// Reset the database to current settings
ResetDatabase();
@@ -625,10 +621,8 @@ namespace FeedCenter
// Switch to normal mode
SetProgressMode(false, 0);
- // Check for update information
- var updateCheckInfo = workerOutput.UpdateResult;
-
- if (updateCheckInfo != null && updateCheckInfo.UpdateAvailable)
+ // Check for update
+ if (UpdateCheck.UpdateAvailable)
newVersionLink.Visibility = Visibility.Visible;
UpdateErrorLink();
@@ -658,9 +652,6 @@ namespace FeedCenter
// Get the input information
var workerInput = (FeedReadWorkerInput) e.Argument;
- // Create the output
- var workerOutput = new FeedReadWorkerOutput();
-
// Setup for progress
var currentProgress = 0;
@@ -696,22 +687,10 @@ namespace FeedCenter
worker.ReportProgress(currentProgress);
// See if we're due for a version check
- if (DateTime.Now - Settings.Default.LastVersionCheck >= Settings.Default.VersionCheckInterval && ApplicationDeployment.IsNetworkDeployed)
+ if (DateTime.Now - Settings.Default.LastVersionCheck >= Settings.Default.VersionCheckInterval)
{
- UpdateCheckInfo updateCheckInfo = null;
-
- try
- {
- // Get the update information
- updateCheckInfo = ApplicationDeployment.CurrentDeployment.CheckForDetailedUpdate(false);
- }
- catch (Exception exception)
- {
- Tracer.WriteException(exception);
- }
-
- // Store the update information in the output
- workerOutput.UpdateResult = updateCheckInfo;
+ // Get the update information
+ UpdateCheck.CheckForUpdate();
// Update the last check time
Settings.Default.LastVersionCheck = DateTime.Now;
@@ -723,9 +702,6 @@ namespace FeedCenter
// Report progress
worker.ReportProgress(currentProgress);
- // Save the output
- e.Result = workerOutput;
-
// Sleep for a little bit so the user can see the update
Thread.Sleep(Settings.Default.ProgressSleepInterval * 3);
}
diff --git a/Application/Options/AboutOptionsPanel.xaml.cs b/Application/Options/AboutOptionsPanel.xaml.cs
index 0e99ef1..d862dab 100644
--- a/Application/Options/AboutOptionsPanel.xaml.cs
+++ b/Application/Options/AboutOptionsPanel.xaml.cs
@@ -1,4 +1,4 @@
-using System.Deployment.Application;
+using FeedCenter.Update;
using System.Reflection;
namespace FeedCenter.Options
@@ -16,7 +16,7 @@ namespace FeedCenter.Options
applicationNameLabel.Text = Properties.Resources.ApplicationDisplayName;
- string version = (ApplicationDeployment.IsNetworkDeployed ? ApplicationDeployment.CurrentDeployment.CurrentVersion.ToString() : "0");
+ string version = UpdateCheck.CurrentVersion.ToString();
versionLabel.Text = string.Format(Properties.Resources.Version, version);
companyLabel.Text = ((AssemblyCompanyAttribute) Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCompanyAttribute), false)[0]).Company;
diff --git a/Application/Properties/AssemblyInfo.cs b/Application/Properties/AssemblyInfo.cs
index c10b651..39c49cd 100644
--- a/Application/Properties/AssemblyInfo.cs
+++ b/Application/Properties/AssemblyInfo.cs
@@ -49,4 +49,4 @@ using System.Windows;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("0.2.*")]
diff --git a/Application/Properties/Resources.Designer.cs b/Application/Properties/Resources.Designer.cs
index 159093f..eab4204 100644
--- a/Application/Properties/Resources.Designer.cs
+++ b/Application/Properties/Resources.Designer.cs
@@ -1279,6 +1279,15 @@ namespace FeedCenter.Properties {
}
}
+ ///
+ /// Looks up a localized string similar to Downloading update....
+ ///
+ public static string SplashDownloadingUpdate {
+ get {
+ return ResourceManager.GetString("SplashDownloadingUpdate", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Installing update....
///
diff --git a/Application/Properties/Resources.resx b/Application/Properties/Resources.resx
index 1244ad6..9df5496 100644
--- a/Application/Properties/Resources.resx
+++ b/Application/Properties/Resources.resx
@@ -166,6 +166,9 @@
Installing update...
+
+ Downloading update...
+
Maintaining database...
diff --git a/Application/Properties/Settings.Designer.cs b/Application/Properties/Settings.Designer.cs
index 884de74..b0feb84 100644
--- a/Application/Properties/Settings.Designer.cs
+++ b/Application/Properties/Settings.Designer.cs
@@ -272,5 +272,23 @@ namespace FeedCenter.Properties {
this["MultipleLineDisplay"] = value;
}
}
+
+ [global::System.Configuration.ApplicationScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("FeedCenterSetup.xml")]
+ public string VersionFile {
+ get {
+ return ((string)(this["VersionFile"]));
+ }
+ }
+
+ [global::System.Configuration.ApplicationScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("http://server/FeedCenter/")]
+ public string VersionLocation {
+ get {
+ return ((string)(this["VersionLocation"]));
+ }
+ }
}
}
diff --git a/Application/Properties/Settings.settings b/Application/Properties/Settings.settings
index 096f6f6..9dbaea6 100644
--- a/Application/Properties/Settings.settings
+++ b/Application/Properties/Settings.settings
@@ -65,5 +65,11 @@
Normal
+
+ FeedCenterSetup.xml
+
+
+ http://server/FeedCenter/
+
\ No newline at end of file
diff --git a/Application/SplashWindow.xaml.cs b/Application/SplashWindow.xaml.cs
index b4d1679..0025073 100644
--- a/Application/SplashWindow.xaml.cs
+++ b/Application/SplashWindow.xaml.cs
@@ -1,12 +1,10 @@
-using Common.Debug;
-using FeedCenter.Data;
+using FeedCenter.Data;
using FeedCenter.Properties;
+using FeedCenter.Update;
using System;
using System.Collections.Generic;
using System.ComponentModel;
-using System.Deployment.Application;
using System.Threading;
-using System.Windows;
using System.Windows.Threading;
namespace FeedCenter
@@ -51,7 +49,7 @@ namespace FeedCenter
_dispatcher = Dispatcher.CurrentDispatcher;
// Get the version to display
- string version = (ApplicationDeployment.IsNetworkDeployed ? ApplicationDeployment.CurrentDeployment.CurrentVersion.ToString() : "0");
+ string version = UpdateCheck.CurrentVersion.ToString();
// Show the version
lblVersion.Content = string.Format(Properties.Resources.Version, version);
@@ -183,16 +181,14 @@ namespace FeedCenter
private void LoadProgressSteps()
{
// Load the progress steps
- _progressSteps.Add(new ProgressStep(ProgressKey.Update, Properties.Resources.SplashCheckingForUpdate, CheckUpdate));
- _progressSteps.Add(new ProgressStep(ProgressKey.Update, Properties.Resources.SplashInstallingUpdate, DownloadUpdate));
- _progressSteps.Add(new ProgressStep(ProgressKey.Update, Properties.Resources.SplashRestarting, RestartAfterUpdate));
-
_progressSteps.Add(new ProgressStep(ProgressKey.DatabaseCreate, Properties.Resources.SplashCheckingForDatabase, CheckDatabase));
_progressSteps.Add(new ProgressStep(ProgressKey.DatabaseCreate, Properties.Resources.SplashCreatingDatabase, CreateDatabase));
_progressSteps.Add(new ProgressStep(ProgressKey.DatabaseUpdate, Properties.Resources.SplashUpdatingDatabase, UpdateDatabase));
_progressSteps.Add(new ProgressStep(ProgressKey.DatabaseMaintenance, Properties.Resources.SplashMaintainingDatabase, MaintainDatabase));
+
+ _progressSteps.Add(new ProgressStep(ProgressKey.Update, Properties.Resources.SplashCheckingForUpdate, CheckUpdate));
}
private static bool CheckUpdate()
@@ -201,47 +197,8 @@ namespace FeedCenter
if (!Settings.Default.CheckVersionAtStartup)
return false;
- // If the application isn't install then skip
- if (!ApplicationDeployment.IsNetworkDeployed)
- return false;
-
- UpdateCheckInfo updateCheckInfo;
-
- try
- {
- // Get detailed version information
- updateCheckInfo = ApplicationDeployment.CurrentDeployment.CheckForDetailedUpdate(false);
- }
- catch (Exception exception)
- {
- // Log the exception
- Tracer.WriteException(exception);
-
- // No update at this time
- return false;
- }
-
- // Return if an update is available
- return updateCheckInfo.UpdateAvailable;
- }
-
- private static bool DownloadUpdate()
- {
- // Download and installthe update
- ApplicationDeployment.CurrentDeployment.Update();
-
- return true;
- }
-
- private bool RestartAfterUpdate()
- {
- // We need to restart
- ((App) Application.Current).Restart = true;
-
- // Cancel the worker
- _backgroundWorker.CancelAsync();
-
- return true;
+ // Return if the check worked and an update is available
+ return UpdateCheck.CheckForUpdate() && UpdateCheck.UpdateAvailable;
}
private static bool CheckDatabase()
diff --git a/Application/Update/UpdateCheck.cs b/Application/Update/UpdateCheck.cs
new file mode 100644
index 0000000..a0d6a38
--- /dev/null
+++ b/Application/Update/UpdateCheck.cs
@@ -0,0 +1,64 @@
+using FeedCenter.Properties;
+using System;
+using System.Diagnostics;
+using System.IO;
+using System.Net;
+using System.Reflection;
+using System.Threading.Tasks;
+
+namespace FeedCenter.Update
+{
+ public static class UpdateCheck
+ {
+ public static VersionFile VersionFile { get; private set; }
+ public static string LocalInstallFile { get; private set; }
+
+ public static bool UpdateAvailable { get; private set; }
+
+ public static Version CurrentVersion
+ {
+ get { return Assembly.GetExecutingAssembly().GetName().Version; }
+ }
+
+ public static bool CheckForUpdate()
+ {
+ VersionFile = VersionFile.Load();
+
+ if (VersionFile == null)
+ return false;
+
+ var serverVersion = VersionFile.Version;
+ var localVersion = CurrentVersion;
+
+ UpdateAvailable = serverVersion > localVersion;
+
+ return true;
+ }
+
+ internal static async Task DownloadUpdate()
+ {
+ if (VersionFile == null)
+ return false;
+
+ var remoteFile = Settings.Default.VersionLocation + VersionFile.InstallFile;
+
+ LocalInstallFile = Path.Combine(Path.GetTempPath(), VersionFile.InstallFile);
+
+ var webClient = new WebClient();
+
+ await webClient.DownloadFileTaskAsync(new Uri(remoteFile), LocalInstallFile);
+
+ return true;
+ }
+
+ internal static bool InstallUpdate()
+ {
+ if (VersionFile == null)
+ return false;
+
+ Process.Start(LocalInstallFile, "/passive");
+
+ return true;
+ }
+ }
+}
diff --git a/Application/Update/VersionFile.cs b/Application/Update/VersionFile.cs
new file mode 100644
index 0000000..cb9b833
--- /dev/null
+++ b/Application/Update/VersionFile.cs
@@ -0,0 +1,49 @@
+using Common.Debug;
+using FeedCenter.Properties;
+using System;
+using System.Xml.Linq;
+
+namespace FeedCenter.Update
+{
+ public class VersionFile
+ {
+ public Version Version { get; set; }
+ public string InstallFile { get; set; }
+ public DateTime InstallCreated { get; set; }
+
+ public static VersionFile Load()
+ {
+ try
+ {
+ var document = XDocument.Load(Settings.Default.VersionLocation + Settings.Default.VersionFile);
+
+ var versionInformationElement = document.Element("versionInformation");
+
+ if (versionInformationElement == null)
+ return null;
+
+ var versionElement = versionInformationElement.Element("version");
+ var installFileElement = versionInformationElement.Element("installFile");
+ var installCreatedElement = versionInformationElement.Element("installCreated");
+
+ if (versionElement == null || installFileElement == null || installCreatedElement == null)
+ return null;
+
+ var versionFile = new VersionFile
+ {
+ Version = Version.Parse(versionElement.Value),
+ InstallFile = installFileElement.Value,
+ InstallCreated = DateTime.Parse(installCreatedElement.Value)
+ };
+
+ return versionFile;
+ }
+ catch (Exception exception)
+ {
+ Tracer.WriteException(exception);
+
+ return null;
+ }
+ }
+ }
+}
diff --git a/Application/VersionCheck.cs b/Application/VersionCheck.cs
index 97cab28..ade8d99 100644
--- a/Application/VersionCheck.cs
+++ b/Application/VersionCheck.cs
@@ -2,44 +2,23 @@
using FeedCenter.Properties;
using System;
using System.ComponentModel;
-using System.Deployment.Application;
using System.Windows;
+using FeedCenter.Update;
using Application = System.Windows.Forms.Application;
namespace FeedCenter
{
internal static class VersionCheck
{
- public static void DisplayUpdateInformation(bool showIfCurrent)
+ public static async void DisplayUpdateInformation(bool showIfCurrent)
{
- if (!ApplicationDeployment.IsNetworkDeployed)
- return;
-
- UpdateCheckInfo updateCheckInfo = null;
-
- try
- {
- updateCheckInfo = ApplicationDeployment.CurrentDeployment.CheckForDetailedUpdate(false);
- }
- catch (Exception exception)
- {
- Tracer.WriteException(exception);
- }
-
- DisplayUpdateInformation(updateCheckInfo, showIfCurrent);
- }
-
- public static void DisplayUpdateInformation(UpdateCheckInfo updateCheckInfo, bool showIfCurrent)
- {
- // If we didn't get any information then do nothing
- if (updateCheckInfo == null)
- return;
+ UpdateCheck.CheckForUpdate();
// Check for an update
- if (updateCheckInfo.UpdateAvailable)
+ if (UpdateCheck.UpdateAvailable)
{
// Load the version string from the server
- Version serverVersion = updateCheckInfo.AvailableVersion;
+ Version serverVersion = UpdateCheck.VersionFile.Version;
// Format the check title
string updateCheckTitle = string.Format(Resources.UpdateCheckTitle, Resources.ApplicationDisplayName);
@@ -52,7 +31,10 @@ namespace FeedCenter
return;
// Get the update
- ApplicationDeployment.CurrentDeployment.Update();
+ await UpdateCheck.DownloadUpdate();
+
+ // Install the update
+ UpdateCheck.InstallUpdate();
// Set to restart
((App) System.Windows.Application.Current).Restart = true;
@@ -101,18 +83,16 @@ namespace FeedCenter
_backgroundWorker = null;
}
- static void HandleBackgroundWorkerDoWork(object sender, DoWorkEventArgs e)
+ private static void HandleBackgroundWorkerDoWork(object sender, DoWorkEventArgs e)
{
- // If the application isn't installed then do nothing
- if (!ApplicationDeployment.IsNetworkDeployed)
- return;
-
e.Result = null;
try
{
+ UpdateCheck.CheckForUpdate();
+
// Get the update information and set it into the result
- e.Result = ApplicationDeployment.CurrentDeployment.CheckForDetailedUpdate(false);
+ e.Result = UpdateCheck.UpdateAvailable;
}
catch (Exception exception)
{
@@ -123,7 +103,7 @@ namespace FeedCenter
private static void HandleBackgroundWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
// Display any update info
- DisplayUpdateInformation(e.Result as UpdateCheckInfo, false);
+ DisplayUpdateInformation(false);
}
#endregion
diff --git a/Application/app.config b/Application/app.config
index fbdea5c..0eddb15 100644
--- a/Application/app.config
+++ b/Application/app.config
@@ -34,7 +34,7 @@
True
-
+
False
@@ -52,7 +52,7 @@
False
-
+
1500
@@ -79,6 +79,12 @@
01:00:00
+
+ FeedCenterSetup.xml
+
+
+ http://server/FeedCenter/
+
diff --git a/Bootstrapper/Bootstrapper.wixproj b/Bootstrapper/Bootstrapper.wixproj
index f805b8f..f6245ae 100644
--- a/Bootstrapper/Bootstrapper.wixproj
+++ b/Bootstrapper/Bootstrapper.wixproj
@@ -24,6 +24,10 @@
+
+ ..\..\..\Public\WixBalExtensionExt\wixext\bin\Debug\WixBalExtensionExt.dll
+ WixBalExtensionExt
+
$(WixExtDir)\WixNetFxExtension.dll
WixNetFxExtension
@@ -32,10 +36,6 @@
..\..\WixFileVersionExtension\bin\Release\WixFileVersionExtension.dll
WixFileVersionExtension
-
- $(WixExtDir)\WixBalExtension.dll
- WixBalExtension
-
@@ -57,7 +57,9 @@
- D:\Code\Personal\CreateInstallDescriptor\bin\Debug\CreateInstallDescriptor.exe !(TargetPath) $(TargetDir)\$(TargetName).xml
+ D:\Code\Personal\CreateInstallDescriptor\bin\Debug\CreateInstallDescriptor.exe !(TargetPath) $(TargetDir)\$(TargetName).xml
+copy $(TargetDir)\$(TargetName).xml \\server\d\FeedCenter
+copy $(TargetDir)\$(TargetName).exe \\server\d\FeedCenter