Squirrel / Squirrel.Windows

An installation and update framework for Windows desktop apps
MIT License
7.31k stars 1.03k forks source link

Shortcut name for MyApp-Env defaulting to MyApp #679

Open enoumen opened 8 years ago

enoumen commented 8 years ago

I am using Squirrel to package and install MyApp. I want to be able to differentiate my same App deployed for different environments with different shortcuts. I have MyApp-Dev.exe and MyApp-Qual.exe but when I install them they all create the same shortcut as MyApp (MyApp.lnk) and erase the existing shortcut on Desktop. How can I create the app with squirrel and require the shortcut to match exactly the executable (Example: MyApp-Qual.lnk for MyApp-Qual.exe, MyApp-Dev.lnk for MyApp-Dev.exe , MyApp.lnk for MyApp.exe) Thanks Etienne

jjwilliams42 commented 8 years ago

I would also like to know how to do this. I'm afraid this repo is dead though :(

dealproc commented 8 years ago

You may need to take over the SquirrelAwareApp events and handle it yourself. Give that a whirl and see if that makes a diff.

It's going to involve a little msbuild trickery as well, so you can produce the MyApp-{Channel}.exe, but it might be doable.

Maybe something like this:

using (var mgr = new UpdateManager(appConfig.UpdateUri.AbsoluteUri)) {
    var fInfo = new FileInfo(Assembly.GetExecutingAssembly().Location);
    var exeName = fInfo.Name;

    var locations = ShortcutLocation.Startup | ShortcutLocation.Desktop | ShortcutLocation.StartMenu;

    SquirrelAwareApp.HandleEvents(
        v => mgr.CreateShortcutsForExecutable(exeName, locations, false),
        v => mgr.CreateShortcutsForExecutable(exeName, locations, true),
        v => mgr.RemoveShortcutsForExecutable(exeName, locations),
        v => mgr.RemoveShortcutsForExecutable(exeName, locations)
    );
}

specifically the second and third line, where I'm dynamically capturing the exe name, instead of assuming it is MyApp.exe