Squirrel / Squirrel.Windows

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

Auto Updating doesn't appear to be working for me #365

Closed sachabarber closed 5 years ago

sachabarber commented 9 years ago

I am new to Squirrel for Windows, but have some exposure to ClickOnce.

General Notes I am using the standard "Releases" folder to host my releases. I have a working web site which looks at a "dist" folder.

Initial Release So after a bit of pain I have something almost working here.

  1. I create the nuspec file
  2. I create the nuget package
  3. I do a release of current app version
  4. Copy from releases to dist folder
  5. run setup.exe from browser

App is install all is good.

New Release

  1. I then edit my codebase to contain the following

       var updateManager = new UpdateManager(@"http://localhost:85/", "SqTest2");
       using (updateManager)
       {
           var updateInfo = await updateManager.CheckForUpdate();
           if (updateInfo == null || !updateInfo.ReleasesToApply.Any())
           {
               return;
           }
           else
           {
               var releases = updateInfo.ReleasesToApply;
               await updateManager.DownloadReleases(releases, _ => { });
               await updateManager.ApplyReleases(updateInfo, _ => { });
           }
       } 
  2. I then also change the assembly version
  3. I create the nuget package (this generates full/delta nuget packages)
  4. I do a release of current app version
  5. Copy from releases to dist folder

At this point I am expecting to be able to run installed app, and it auto update to latest version. This does NOT happen, it just runs old version.

Strange thing is, if I just run the web site setup,exe again I do get the latest version.

anaisbetts commented 9 years ago

The HTTP URL is obscuring what's going on a bit, can you just use a path instead to illustrate where you're pulling updates from?

sachabarber commented 9 years ago

So I have a web site which is http://localhost (port 85) which is set up to point to the folder C:\Users\barbers\Desktop\SqTest2\dist. The new releases are built to C:\Users\barbers\Desktop\SqTest2\Releases which for me right now contains the following list of files

I then copy all of these to the "dist" folder C:\Users\barbers\Desktop\SqTest2\dist (which acts as the folder for the IIS web site).

Do you need more information than that? Are you saying the autoupdater stuff in the app should be pointing to an actual path? That doesn't make too much sense to me, I would think this should be a url of well known web site.

Like I say though, I a completely new to Squirrel for Windows, and just want to get it working as I loath Mage.exe (lost more hours to that EXE than I care to mention)

anaisbetts commented 9 years ago

Are you saying the autoupdater stuff in the app should be pointing to an actual path? That doesn't make too much sense to me, I would think this should be a url of well known web site.

In production, the autoupdater stuff will point to an HTTPS URL, just like you've set it up. However, when you're testing updates locally, you can instead just point it to a local folder, because that's way easier to set up / debug, than spinning up a dummy HTTP server

anaisbetts commented 9 years ago

What happens to your local installed app folder when you run the code (i.e. C:\Users\NAME\AppData\Local\SqTest2? Do you see a new app-VERSION folder?)

sachabarber commented 9 years ago

Yes I see a folder called this

C:\Users\barbers\AppData\Local\SqTest2

Which contains the following files

anaisbetts commented 9 years ago

@sachabarber Ok - what does your app's shortcut point to?

sachabarber commented 9 years ago

I am not at work now (where I am trying this all out). I suspect I just need to change the auto updater to use a folder. The web site I setup is not HTTPS, it is standard HTTP.

I'll try and get it working with directory auto updater, and if that works I plan to write this all up in a semi-useful guide.

It looks very promising, but could be documented a bit better (sorry dude). It is good work no doubt there, just a bit hard to piece the bits together so far.

sachabarber commented 9 years ago

Paul

So I check out where the app shortcut was pointing to. It points to the folder

C:\Users\barbers\AppData\Local\SqTest2

So I tried using that for the UpdateManager path instead of web Url. So I then made a new release, and copied the auto generated release folder items to the path

C:\Users\barbers\Desktop\SqTest2\dist

I then ran the setup.exe from that path. This installed everything fine. I then tried to run the installed app. When I start the app, it crashed saying the following

System.Exception: The file C:\Users\barbers\AppData\Local\SqTest2\RELEASES does not exist, something is probably broken with your application at Squirrel.UpdateManager.CheckForUpdateImpl.d__28.MoveNext()

At this point the installed app is configured to have its update path set to C:\Users\barbers\AppData\Local\SqTest2, and the shortcut also points to this folder.

I then checked the C:\Users\barbers\AppData\Local\SqTest2, and it does not contains a folder for the current release, or even a file called "RELEASES". The auto generated "RELEASES" folder (which for me is this path) C:\Users\barbers\Desktop\SqTest2\Releases does contain that file. In fact here is everthing is contains for current release

RELEASES Setup.exe
SqTest2-1.8.0.0-full.nupkg
SqTest2-1.9.0.0-delta.nupkg
SqTest2-1.9.0.0-full.nupkg
SqTest2-2.0.0.0-delta.nupkg
SqTest2-2.0.0.0-full.nupkg
SqTest2-2.1.0.0-delta.nupkg
SqTest2-2.1.0.0-full.nupkg

As the error message seems to be complaining about the lack of a "RELEASES" file, my assumption was that this C:\Users\barbers\AppData\Local\SqTest2 path, can't be the one that is used for the UpdateManager path, as it only seems to get a new version of the app copied there after a successful run, and it is also missing the "RELEASES" file. Which seems very strange as this is the folder with the actual update.exe in it.

So I uninstalled the app.

Then created a new release where I changed the UpdateManager to be the C:\Users\barbers\Desktop\SqTest2\dist folder (which does have the RELEASES file in it (but there is not Update.exe in this folder). Did a new release, copied the files to C:\Users\barbers\Desktop\SqTest2\dist (from autogenerated Squirel releases folder), ran setup.exe from C:\Users\barbers\Desktop\SqTest2\dist. This installed a new app which is runable, and also ends up creating a new version of the app in the C:\Users\barbers\AppData\Local\SqTest2.

I then thought ok it did not crash, perhaps all I need to do now is create yet another new release and copy the files to the C:\Users\barbers\Desktop\SqTest2\dist (which is where setup.exe was run from), and it will auto update.

It didn't. Which does not suprise me, as the app shortcut is setup to point to the C:\Users\barbers\AppData\Local\SqTest2, which is also where update.exe is. The C:\Users\barbers\Desktop\SqTest2\dist doesnt contain a update.exe

What does confuse the buggery out of me, is how I a meant to configure this UpdateManager path to point to the C:\Users\barbers\AppData\Local\SqTest2 directory when this seems to crash as soon as I do a new release, due to the required app-x.x.x.x not being present and also the lack of a "RELEASES" file there

Seems a catch 22 situation. whatever I do seems to result in either crash or no update occurring

Could you be a sport and just tell me how this is meant to work.

stajs commented 9 years ago

To risk stating the obvious, it looks like you have a pathing problem: you aren't telling the UpdateManager the right path to your RELEASES file. I found it a bit hard to follow your previous comment, but it looks like you just need to tell the UpdateManager to use the dist folder path. And I'd stick with folder path over a URL until you get it working locally.

If it helps to see a working example (and I'm not saying this is best practice), I half-assed-automated the packaging of our app and documented the release process here:

https://github.com/lic-nz/Malone/wiki/Release

I made the update URL a config setting, so you can modify the installed versions config to test against a local path. HTH

sachabarber commented 9 years ago

I agree this post of mine is hard to follow, but so is the NON existent Squirel documentation :-)

I could not see in your example where you even use the suggested "updateManager" code. I watched a video of Paul Betts showing Scott Hansleman how to use Squirrel. And even in that video he put the code in for UpdateManager, and then went on to comment it out before showing it working.

I basically have it all working apart from the Auto update stuff. I need to try that again. I like how you are creating the Nuget in code though they seems good.

Update

So I just tried exactly the same setup again and it all seems to work now. Only thing I did changed was I wrapped UpdateManager stuff in Task.Run(..).

There is one other issue, when I run the NuGet command line (something like)

squirrel --releasify C:\Users\barbers\Desktop\SqTest2\SqTest2\SqTest2.2.6.0.0.nupkg

I get this exception

Squirrel.com : System.Exception: Couldn't find file for package in .: squirrel.windowsAt line:1 char:1

Squirrel currently seems to not like having packages.config file present and blows up on that, at least it does for me. If I rename the packages.config when I do a release to XXXpackages.config and all is ok with release process. I then rename it back afterwards. Start my UI and close it, and it auto updates on closing.

All cool

If I could get past this last issue I would be happy

stajs commented 9 years ago

For reference, this is where I check for updates:

https://github.com/lic-nz/Malone/blob/master/LIC.Malone.Client.Desktop/ViewModels/AppViewModel.cs#L444

I use a slightly expanded version of that "suggested" code from your initial comment. You'll see that the method is marked async in order to allow the await's. Without seeing what modifiers you have on your containing method, it's possible adding the Task.Run() ended up being another way to do the same thing.

As for your update, I'm not sure what is happening there. With Squirrel built on nuget concepts you may be right that having a packages.config just kills it. But why do you need one? All your dependencies should be explicitly included...? Anyway, I'd suggest creating a separate issue to avoid mixing these bug threads and also properly formatting that stack trace. ATM, I can't tell if GitHubs auto-formatting has decided to truncate or mangle some important information in there.

sachabarber commented 9 years ago

I am not sure what you mean about why would I need a package.config. I do this

  1. I have a UI which uses several NuGet packages, so there is a package.config that contains all the packages used by the UI in the project
  2. I then create a NuSpec file for the UI project, where I create the NuSpec in same place as UIs csproj file location (which happens to end up in the same folder as the actual UIs package.config file)
  3. I then realeasify everything, and that breaks due to (apparently) having a package.config in the same folder as the nuspec file (I guess). Perhaps I should create the Nuspec file to new folder and do realeasify from a folder that does not have a package.config in it

I agree I should move some of this to new thread though. Ill try that, thanks for trying to help me here

stajs commented 9 years ago

Sorry, I think I misunderstood you. I thought you might have been including a packages.config inside your nupkg.

What version of Squirrel are you on? I'm using 0.99.0 and can't repro that issue. A few things:

  1. Yeah, I build out to a separate location, but I verified that I could still build all back in the root of my UI's csproj. And my layout is the same as yours: csproj, packages.config and nuspec all in the same folder. image
  2. I also tested adding a packages.config in the folder where I build, and it worked fine: image
  3. You missed describing a step above where you create a suitable nupkg. I assume that is just an oversight and you actually do have one. And by "suitable" I mean the dependencies are explicitly included, you aren't doing anything weird with recursively nuget'ing things... I dunno just chucking ideas out there. It might be worth showing the contents of your nupkg to check.
  4. I call Squirrel from the command line, but also tested using the Package Manager Console inside VS.

The releasify process AFAIK will only operate on that single nupkg, so I don't see how having a packages.config sitting next to it matters. And it doesn't make a difference from my testing. It could be worth you forking my project and try releasifying that, because if it that doesn't work for you it might point to something being borked with your environment.

Thieum commented 5 years ago

@shiftkey discussion has ended with no further issues - this can be closed.

OfficialMudasir commented 3 years ago

The HTTP URL is obscuring what's going on a bit, can you just use a path instead to illustrate where you're pulling updates from?

can you please tell me how to generate Update.exe after issuing the command squirrel --releasify "updated nuget package name".nupkg because I am not able to generate that.

vernou commented 3 years ago

The command Squirrel --releasify generate "Setup.exe". This executable install the app and deploy the "Update.exe" in %localappdata%\<AppName>\Update.exe.

But the "Update.exe" is "Squirrel.exe" (used in the command Squirrel --releasify) that is duplicated, renamed and integrated in the "Setup.exe". You can :

  1. Download the packge NuGet Squirrel.Windows
  2. Unzip the package (nuspkg is just a zip)
  3. Go in "tools" folder
  4. Copy the file "Squirrel.exe"
  5. Rename the copy "Update.exe"