Squirrel / Squirrel.Windows

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

AppUpdate Custom Event not working #1621

Open veevandyke opened 4 years ago

veevandyke commented 4 years ago

Squirrel version(s) 1.9

Description Installation works. App is squirrel-aware as per log. First Run, Initial Install, Uninstall works. AppUpdate will NOT call.

Steps to recreate Install app. Update app. Code does not run. (Procedure not called.) Note; SquirrelTemp log is only accessed on the initial install and nothing logs for updates.

Expected behavior Should hit my custom events. (This is an issue because all my shortcuts are still pointing to the previous version.)

Actual behavior Nothing.

Additional information Perhaps this is because I am misunderstanding WHEN this will be called? My assumption was that the AppUpdate event would be called on the launch after an update is installed (i.e. the first time the new version launches.) however, the first item in each of my Squirrel custom events is an event log entry and everything else is being called beautifully! Only the AppUpdate is never called.

As a current workaround, I am writing the version to the registry and then testing the registry value vs. the actual version value and if it's different, I am running my code, but I'd rather use the innate Squirrel functions.

Event Wireup Code:

        Private Sub MyApplication_Startup(sender As Object, e As StartupEventArgs) Handles Me.Startup
            Application.Log.WriteEntry("Datacomp8 Starting Up. 1029.")
            Try
                Dim ver As System.Version = New System.Version
                Dim install As Action(Of Version) = AddressOf mSquirrel.squirrelInitialInstall
                Dim update As Action(Of Version) = AddressOf mSquirrel.squirrelAppUpdate
                Dim uninstall As Action(Of Version) = AddressOf mSquirrel.squirrelAppUninstall
                Dim firstRun As Action = AddressOf mSquirrel.squirrelFirstRun
                SquirrelAwareApp.HandleEvents(onInitialInstall:=install, onAppUpdate:=update, onAppUninstall:=uninstall, onFirstRun:=firstRun)
            Catch ex As Exception
                My.Application.Log.WriteException(ex)
            End Try
            Application.EnableVisualStyles() = True
        End Sub

Update Procedure:

    Public Sub squirrelAppUpdate(v As Version)
        My.Application.Log.WriteEntry("Squirrel App Updated: Datacomp8 App Updated To Current Version", TraceEventType.Information)
        Try
            Using mgr As New UpdateManager(updateURL)
                mgr.CreateShortcutForThisExe()
                mgr.CreateShortcutsForExecutable("Datacomp8.exe", ShortcutLocation.Desktop, True)
                mgr.CreateShortcutsForExecutable("Datacomp8.exe", ShortcutLocation.StartMenu, True)

                Dim sqPath As String = Path.Combine(mgr.RootAppDirectory.ToString())
                Dim appPath As String = Path.Combine(sqPath, "app-" & Version)
                Dim vstoPath As String = Path.Combine(sqPath, "VSTO")
                Dim roPath As String = Path.Combine(sqPath, "app-" & Version, "RUNONCE")

                UpdateConfigFiles(appPath)
                RunOnceFolders(roPath, False)
                UpdateVSTOFiles(vstoPath)
            End Using
        Catch ex As Exception
            My.Application.Log.WriteException(ex)
        End Try
    End Sub
owns commented 4 years ago

Hello @veevandyke . I know this was back in may... but did you make your app squirrel aware by adding the assembly metadata info?

<Assembly: AssemblyMetadata("SquirrelAwareVersion", "1")>