Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

Shortcuts not working with console app #61

Closed
Mat-Stevenson-Simworx opened this issue Mar 24, 2022 · 5 comments
Closed

Shortcuts not working with console app #61

Mat-Stevenson-Simworx opened this issue Mar 24, 2022 · 5 comments
Labels
enhancement New feature or request

Comments

@Mat-Stevenson-Simworx
Copy link

I v been trying to get Squirrel working with an internal tool that is just a console app. Everything seems correct during pack and install, after installation it runs as expected but the shortcuts dont work as the exe they link to doesnt exist. Looking at a WPF app I use Squirrel with there is a exe at the root of the installation folder that seems to be missing in this case.

I have created a test app that shows the issue. Any help on this issue would be appreciated.

See below log from pack command.

[INFO] NugetConsole: Starting to package 'C:\Users\m.stevenson\AppData\Local\SquirrelClowdTemp\tempa\SquirrelConsoleTest.nuspec'
[INFO] NugetConsole: Successfully created package 'C:\Users\m.stevenson\AppData\Local\SquirrelClowdTemp\tempa\SquirrelConsoleTest.1.0.0.nupkg'.
[INFO] Program: Package dependencies (from '--framework' argument) resolved as: net6.0.2-x64
[INFO] DotnetUtil: Extracting Update.exe resources to temp directory
[INFO] DotnetUtil: Patching Update.exe icon

[INFO] DotnetUtil: Re-packing Update.exe bundle
[INFO] Program: Creating release for package: C:\Development\Tests\SquirrelConsoleTest\releases\net6.0\SquirrelConsoleTest.1.0.0.nupkg
[INFO] ReleasePackage: Creating release package: C:\Development\Tests\SquirrelConsoleTest\releases\net6.0\SquirrelConsoleTest.1.0.0.nupkg => C:\Development\Tests\SquirrelConsoleTest\releases\net6.0\SquirrelConsoleTest-1.0.0-full.nupkg
[INFO] ReleasePackage: Removing unnecessary data
[INFO] ReleasePackage: No release notes found in C:\Users\m.stevenson\AppData\Local\SquirrelClowdTemp\tempc\SquirrelConsoleTest.nuspec
[INFO] Program: Package architecture: X64 (implicit, from a SquirrelAware binary)
[INFO] Program: Creating stub executables
[INFO] EasyZip: Compressing 'C:\Users\m.stevenson\AppData\Local\SquirrelClowdTemp\tempc' to 'C:\Development\Tests\SquirrelConsoleTest\releases\net6.0\SquirrelConsoleTest-1.0.0-full.nupkg'...

[INFO] Program: Creating Setup bundle
[INFO] Program: Done

Installer log

2022-03-24 10:30:13.7818 [INFO] - Program: Starting Squirrel Updater: --setup C:\Users\M5072~1.STE\AppData\Local\Temp\squCA02.tmp.nupkg
2022-03-24 10:30:13.8720 [INFO] - Program: Extracting bundled app data from 'C:\Users\M5072~1.STE\AppData\Local\Temp\squCA02.tmp.nupkg'.
2022-03-24 10:30:14.1244 [INFO] - Program: Starting package install from directory C:\Users\m.stevenson\AppData\Local\SquirrelClowdTemp\tempa
2022-03-24 10:30:14.2191 [INFO] - Program: Starting install, writing to C:\Users\m.stevenson\AppData\Local\SquirrelClowdTemp\tempa
2022-03-24 10:30:14.2482 [INFO] - Program: About to install to: C:\Users\m.stevenson\AppData\Local\SquirrelConsoleTest
2022-03-24 10:30:14.2482 [WARN] - Program: Install path C:\Users\m.stevenson\AppData\Local\SquirrelConsoleTest already exists, burning it to the ground
2022-03-24 10:30:14.9399 [INFO] - CheckForUpdateImpl: Reading RELEASES file from C:\Users\m.stevenson\AppData\Local\SquirrelClowdTemp\tempa
2022-03-24 10:30:14.9399 [INFO] - CheckForUpdateImpl: First run, starting from scratch
2022-03-24 10:30:15.0087 [INFO] - ApplyReleasesImpl: Writing files to app directory: C:\Users\m.stevenson\AppData\Local\SquirrelConsoleTest\app-1.0.0
2022-03-24 10:30:15.6106 [INFO] - ApplyReleasesImpl: Squirrel Enabled Apps: [C:\Users\m.stevenson\AppData\Local\SquirrelConsoleTest\app-1.0.0\SquirrelConsoleTest.exe]
2022-03-24 10:30:16.2076 [INFO] - ApplyReleasesImpl: Starting fixPinnedExecutables
2022-03-24 10:30:16.4613 [INFO] - ApplyReleasesImpl: cleanDeadVersions: checking for version 1.0.0
2022-03-24 10:30:16.4613 [INFO] - ApplyReleasesImpl: cleanDeadVersions: exclude new version folder app-1.0.0
2022-03-24 10:30:16.5380 [INFO] - InstallHelperImpl: Writing uninstaller registry entry
2022-03-24 10:30:16.5510 [INFO] - InstallHelperImpl: There was no icon found, will use 'C:\Users\m.stevenson\AppData\Local\SquirrelConsoleTest\app-1.0.0\SquirrelConsoleTest.exe' for uninstall icon.
2022-03-24 10:30:16.6055 [INFO] - Program: Finished Squirrel Updater
@caesay
Copy link
Member

caesay commented Mar 24, 2022

Hi Mat, Squirrel has never worked with console apps and I've not taken the time to look at this since I created the fork. I believe the primary issue is that, because of #24 we need to use stubexecutables. (your shortcut points to a "stub" in the root application directory, instead of to the version binary in app-1.0.0). This stub exe is GUI-only, and if it tried to launch a console process the console would not actually "attach" and you would not see any output from your app.

This is tracked in the upstream issues Squirrel#1491 and Squirrel#1098.

I think that we should be able to support console apps, so I will leave this open as a feature request until I can look at it or someone else does.

There are three possible approaches:

  • for console apps, shortcuts could point directly to the version binary (in app-) and we don't ship stubs for it. (but this comes with all the problems of not having stub executables)
  • instead, we could compile stub executables as a console exe, and switch to gui exe only if the SquirrelAwareApp is also gui, using PEUtils.SetWindowsGraphicalUserInterfaceBit. We would may also need to write some code in the stub to capture the child process std output and forward it to the console host.
  • or, we could wait for Use a 'current' directory instead of 'app-{version}' for the latest app version #24 which would fix this anyway.

@caesay caesay added the enhancement New feature or request label Mar 24, 2022
@Mat-Stevenson-Simworx
Copy link
Author

Thanks for the detailed reply. I v just used the ShellLink class to create a custom shortcut to the exe in the app- folder. Its not clean but does what I need for now. Waiting for #24 seems like the best way forwards to me.

@caesay
Copy link
Member

caesay commented Mar 25, 2022

If you are using ShellLink as a work-around, don't forget to update the shortcut location during updates!

@caesay
Copy link
Member

caesay commented Mar 25, 2022

I have published the pre-release 2.9.5-gdcbdbd. It simply removes the check preventing stub's being created for console apps. I tested this, and it seemed to work nearly perfectly. The stub is a GUI exe, but all it does is launch the console app in a new window and exit. The one downside is that if you run the stub from a console you'll see the console pop-up in a new window instead of the current console. When running shortcuts, or running the stub from windows explorer, it works as expected. This is good enough to close this issue until #24.

@caesay caesay closed this as completed Mar 25, 2022
@Mat-Stevenson-Simworx
Copy link
Author

Perfect. That will work fine for my usecase. Thanks.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants