2

我们正在尝试使用 Squirrel.Windows 为我们的 .NET 应用程序创建安装程序。该应用程序包含多个 .exe 文件。我们使用命令:

squirrel --releasify BIN_PATH\MyApp.2.0.33404.nupkg

但是,当运行setup.exe时,它在桌面上创建多个快捷方式对应多个.exe文件如何指定只创建一个快捷方式?

4

1 回答 1

4

Squirrel 文档指出,为包中的每个 EXE 创建快捷方式是默认行为。

同一个文档页面解释说,要覆盖默认行为,您需要至少让一个 EXE Squirrel 感知,然后根据需要实现 Squirrel 事件处理程序。

您最好通过将以下内容添加到它来制作您想要 Squirrel 的快捷方式的 EXE AssemblyInfo.cs

[assembly: AssemblyMetadata("SquirrelAwareVersion", "1")]

然后在你的 EXE 中实现这样的 Squirrel 事件:

static bool ShowTheWelcomeWizard;
...
static int Main(string[] args) 
{
    // NB: Note here that HandleEvents is being called as early in startup
    // as possible in the app. This is very important! Do _not_ call this
    // method as part of your app's "check for updates" code.

    using (var mgr = new UpdateManager(updateUrl))
    {
        // Note, in most of these scenarios, the app exits after this method
        // completes!
        SquirrelAwareApp.HandleEvents(
          onInitialInstall: v => mgr.CreateShortcutForThisExe(),
          onAppUpdate: v => mgr.CreateShortcutForThisExe(),
          onAppUninstall: v => mgr.RemoveShortcutForThisExe(),
          onFirstRun: () => ShowTheWelcomeWizard = true);
    }
}
于 2017-05-15T16:59:07.963 回答