Installer + auto update on startup

1. installer
2. auto check update on startup
3. auto start on next startup
4. remove command line arguments which breaks squirrel
5. auto generate installer on continue integration
This commit is contained in:
bao-qian
2016-05-07 22:44:38 +01:00
parent 192e4b8877
commit e0b9a81c9b
15 changed files with 171 additions and 111 deletions

View File

@@ -186,7 +186,7 @@ namespace Wox.Helper
public interface ISingleInstanceApp
{
void OnActivate(IList<string> args);
void OnActivate();
}
/// <summary>
@@ -238,23 +238,10 @@ namespace Wox.Helper
/// </summary>
private static IpcServerChannel channel;
/// <summary>
/// List of command line arguments for the application.
/// </summary>
private static IList<string> commandLineArgs;
#endregion
#region Public Properties
/// <summary>
/// Gets list of command line arguments for the application.
/// </summary>
public static IList<string> CommandLineArgs
{
get { return commandLineArgs; }
}
#endregion
#region Public Methods
@@ -266,10 +253,6 @@ namespace Wox.Helper
/// <returns>True if this is the first instance of the application.</returns>
public static bool InitializeAsFirstInstance( string uniqueName )
{
commandLineArgs = GetCommandLineArgs(uniqueName);
//remove execute path itself
commandLineArgs.RemoveAt(0);
// Build unique application Id and the IPC channel name.
string applicationIdentifier = uniqueName + Environment.UserName;
@@ -283,17 +266,9 @@ namespace Wox.Helper
CreateRemoteService(channelName);
return true;
}
// Restart
else if (commandLineArgs.Count > 0 && commandLineArgs[0] == Restart)
{
SignalFirstInstance(channelName, commandLineArgs);
singleInstanceMutex.WaitOne(TimeSpan.FromSeconds(10));
CreateRemoteService(channelName);
return true;
}
else
{
SignalFirstInstance(channelName, commandLineArgs);
SignalFirstInstance(channelName);
return false;
}
}
@@ -398,7 +373,7 @@ namespace Wox.Helper
/// <param name="args">
/// Command line arguments for the second instance, passed to the first instance to take appropriate action.
/// </param>
private static void SignalFirstInstance(string channelName, IList<string> args)
private static void SignalFirstInstance(string channelName)
{
IpcClientChannel secondInstanceChannel = new IpcClientChannel();
ChannelServices.RegisterChannel(secondInstanceChannel, true);
@@ -414,7 +389,7 @@ namespace Wox.Helper
{
// Invoke a method of the remote service exposed by the first instance passing on the command line
// arguments and causing the first instance to activate itself
firstInstanceRemoteServiceReference.InvokeFirstInstance(args);
firstInstanceRemoteServiceReference.InvokeFirstInstance();
}
}
@@ -423,11 +398,9 @@ namespace Wox.Helper
/// </summary>
/// <param name="arg">Callback argument.</param>
/// <returns>Always null.</returns>
private static object ActivateFirstInstanceCallback(object arg)
private static object ActivateFirstInstanceCallback(object o)
{
// Get command line args to be passed to first instance
IList<string> args = arg as IList<string>;
ActivateFirstInstance(args);
ActivateFirstInstance();
return null;
}
@@ -435,7 +408,7 @@ namespace Wox.Helper
/// Activates the first instance of the application with arguments from a second instance.
/// </summary>
/// <param name="args">List of arguments to supply the first instance of the application.</param>
private static void ActivateFirstInstance(IList<string> args)
private static void ActivateFirstInstance()
{
// Set main window state and process command line args
if (Application.Current == null)
@@ -443,7 +416,7 @@ namespace Wox.Helper
return;
}
((TApplication)Application.Current).OnActivate(args);
((TApplication)Application.Current).OnActivate();
}
#endregion
@@ -459,14 +432,13 @@ namespace Wox.Helper
/// <summary>
/// Activates the first instance of the application.
/// </summary>
/// <param name="args">List of arguments to pass to the first instance.</param>
public void InvokeFirstInstance(IList<string> args)
public void InvokeFirstInstance()
{
if (Application.Current != null)
{
// Do an asynchronous call to ActivateFirstInstance function
Application.Current.Dispatcher.BeginInvoke(
DispatcherPriority.Normal, new DispatcherOperationCallback(ActivateFirstInstanceCallback), args);
DispatcherPriority.Normal, new DispatcherOperationCallback(ActivateFirstInstanceCallback));
}
}