Squirrel.Windows
Squirrel.Windows copied to clipboard
Packaging Console Application generates a broken shortcut
I was looking to distribute a console application using Squirrel. I had previously done similar with a WPF application and it worked great.
The install and the updates work as expected, but the shortcuts that are generated do not work correctly. It appears that something with the stub executables could be to blame (PR #868).
After installation the generated shortcut looks like this:
Here are the contents of %LocalAppData%\HelloWorld:
There is a HelloWorld.exe at the root, but it is an empty file (note the size).
Looking a bit further it is clear that when releasify'ing my nuget, it does not generate an execution stub for my exe because it is subsystem 3 (related issue #945).
However on install that 0 byte file shows up and the generated shortcut fails. This may be the same issue that is reported in #967
My questions:
- Is Squirrel is expected to be a deployment solution for console applications?
- If so, is this a bug, or am I doing something wrong?
Squirrel Version: 1.7.7
Sample console application:
namespace HelloWorld
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World");
Task.Run(CheckForUpdate).Wait();
Console.ReadLine();
}
private static async Task CheckForUpdate()
{
using (var updateManager = new UpdateManager(@"C:\SquirrelReleases"))
{
Console.WriteLine($"Current version: {updateManager.CurrentlyInstalledVersion()}");
var releaseEntry = await updateManager.UpdateApp();
Console.WriteLine($"Update Version: {releaseEntry?.Version.ToString() ?? "No update"}");
}
}
}
}
I had a WPF application with Output Type set as "Console Application" (for debugging purposes), I had the same problem. The stub executable was not being created, or was 0kb in size, and the shortcuts were broken. Changing it to "Windows Application" fixed this issue for me.
Unfortunately, this is not your case.
Console apps aren't supported at the moment!
Thanks for the reply @paulcbetts Is this something that would be desirable? I am happy to work on a PR for it.
Maybe? Like, what's your use-case? Putting start menu shortcuts to console apps seems Untoward
In general I agree with you. However in this case it is an internal tool that is used to process data. It pretty much just prompts the user for some values and then processes data. Really was just looking to use Squirrel since ClickOnce is a bit of a pain. Without the shortcut it seems difficult for an average user to start the application. Are there any other features that I am missing?
We were trying to use Squirrel to install/update a console application which is used for a self-hosting process (to be called from within a website), but I guess that won't be possible. If @Keboo wants a use-case for it, this is it! :)
PS: Making it possible to start the console app automatically would also be great (using Topshelf so executing "
I end up manually creating this stub exe file, copied it from another installation, renamed it, put it in a folder "Starter" And manually copying it when application is started, and if exe file does not exists:
if (env.IsProduction())
{
// Copy starter exe
var starterFilePath = Path.Combine(pathToContentRoot, "..", "MyApp.exe");
if (!File.Exists(starterFilePath))
{
var starterFileToCopyPath =
Path.Combine(pathToContentRoot, "Starter", "MyApp.exe");
File.Copy(starterFileToCopyPath, starterFilePath);
}
}
seems to be working PS: this is an asp.net core application
The issue with generating shortcuts for console apps is fixed in version 2.9.5 of my fork here.