Merge pull request #155 from flagbug/portable-shortcut

Added a shortcut location for the application root directory
This commit is contained in:
Paul Betts
2014-12-07 21:43:44 +01:00
3 changed files with 11 additions and 4 deletions

View File

@@ -15,7 +15,11 @@ namespace Squirrel
public enum ShortcutLocation {
StartMenu = 1 << 0,
Desktop = 1 << 1,
Startup = 1 << 2
Startup = 1 << 2,
/// <summary>
/// A shortcut in the application folder, useful for portable applications.
/// </summary>
AppRoot = 1 << 3
}
public interface IUpdateManager : IDisposable, IEnableLogger

View File

@@ -114,7 +114,7 @@ namespace Squirrel
var exePath = Path.Combine(Utility.AppDirForRelease(rootAppDirectory, thisRelease), exeName);
var fileVerInfo = FileVersionInfo.GetVersionInfo(exePath);
foreach (var f in new[] { ShortcutLocation.StartMenu, ShortcutLocation.Desktop, ShortcutLocation.Startup, }) {
foreach (var f in (ShortcutLocation[]) Enum.GetValues(typeof(ShortcutLocation))) {
if (!locations.HasFlag(f)) continue;
var file = linkTargetForVersionInfo(f, zf, fileVerInfo);
@@ -573,6 +573,9 @@ namespace Squirrel
case ShortcutLocation.Startup:
dir = Environment.GetFolderPath (Environment.SpecialFolder.Startup);
break;
case ShortcutLocation.AppRoot:
dir = rootAppDirectory;
break;
}
if (createDirectoryIfNecessary && !Directory.Exists(dir)) {

View File

@@ -459,11 +459,11 @@ namespace Squirrel.Tests
}
var fixture = new UpdateManager.ApplyReleasesImpl("theApp", Path.Combine(path, "theApp"));
fixture.CreateShortcutsForExecutable("SquirrelAwareApp.exe", ShortcutLocation.Desktop | ShortcutLocation.StartMenu | ShortcutLocation.Startup, false);
fixture.CreateShortcutsForExecutable("SquirrelAwareApp.exe", ShortcutLocation.Desktop | ShortcutLocation.StartMenu | ShortcutLocation.Startup | ShortcutLocation.AppRoot, false);
// NB: COM is Weird.
Thread.Sleep(1000);
fixture.RemoveShortcutsForExecutable("SquirrelAwareApp.exe", ShortcutLocation.Desktop | ShortcutLocation.StartMenu | ShortcutLocation.Startup);
fixture.RemoveShortcutsForExecutable("SquirrelAwareApp.exe", ShortcutLocation.Desktop | ShortcutLocation.StartMenu | ShortcutLocation.Startup | ShortcutLocation.AppRoot);
// NB: Squirrel-Aware first-run might still be running, slow
// our roll before blowing away the temp path