Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Launcher.exe can't upgrade a NET 4.8 to 5.0 exe if processor is x86 #149

Closed
alansingfield opened this issue Oct 20, 2021 · 8 comments
Closed
Assignees

Comments

@alansingfield
Copy link

alansingfield commented Oct 20, 2021

Description

The Launcher.exe created by -AddLauncher will not work with -Processor x86

My existing .NET 4.8 ClickOnce project is marked as Processor x86, and I am now migrating to .NET Core.

I need to keep Processor x86 set on the ClickOnce manifest because otherwise, all the existing client installs will not upgrade, it would have to be a new installation.

But - because the Launcher.exe is compiled with the MSIL option, ClickOnce sees the mismatch between this and x86 and refuses to start it.

Other information

The workaround was for me to create my own Launcher.exe with I use instead of running MAGE -AddLauncher.

        static void Main(string[] args)
        {
            string folder = Path.GetDirectoryName(
                Assembly.GetExecutingAssembly().Location);

            string exe = Path.Combine(folder, "MyApp.exe");

            Process.Start(new ProcessStartInfo()
            {
                FileName = exe,
                UseShellExecute = false
            });
        }

This must be compiled with the following settings:

  • Framework: .NET 4.7.1
  • Processor: x86
  • Generate Application Manifest: Off
  • Executable name: Launcher.exe

Of these, the most interesting / unexpected behavior of MAGE is the special treatment the file "Launcher.exe" gets.

It is a hard-coded name within the MAGE executable, when MAGE sees this file in the source folder it:

  • Changes the entryPoint to Launcher.exe from your original executable
  • Amends how the EXE and DLL digests are produced to make them compatible with .NET Core

More notes on the -AddLauncher option

It seems to be doing things in a very unusual manner.
When you specify the executable name after -AddLauncher, it loads an embedded version of Launcher.exe, and edits the resources within it to bake in the chained executable name.
Would it not be possible to simply add some parameters into the section?

  <entryPoint>
    <assemblyIdentity name="Launcher" version="2021.1018.102.0" language="neutral" processorArchitecture="x86" />
    <commandLine file="Launcher.exe" parameters="" />
  </entryPoint>
@simmotech
Copy link

@alansingfield:
Since there are no clues as to what Microsoft plans to fix for the missing bits of ClickOnce (and when), I'm trying a custom Launcher.exe passing environment variables as described in your #113 but also with the other ApplicationDeployment bits too.

Can you give me a clue how to 'poke' in the custom Launcher.exe?
I am new to .Net 6 and just use the Build/Publish option in the GUI currently.
I've not used MAGE before and I can't see an "-Add Launcher" option on the version of MAGE that runs when I start from the Developer Command Prompt for VS 2022

@simmotech
Copy link

Looks like I was looking for a complicated solution to a simple problem - just copying my custom Launcher.exe over the one in C:\Program Files (x86)\Microsoft SDKs\ClickOnce Bootstrapper\Engine did the trick.

Took me a while to work out it had worked though since I pinned my test app to the Taskbar and it would seem that doesn't use Launcher.exe!! Running from the Desktop icon however, it did work

@alansingfield
Copy link
Author

alansingfield commented Nov 19, 2021

Hello Simmotech,

The -AddLauncher parameter is only available on the newer version of MAGE (use dotnet mage rather than mage.exe).

dotnet new tool-manifest --force
dotnet tool install microsoft.dotnet.mage --version 5.0.0
dotnet mage -AddLauncher 'YourApp.exe' -TargetDirectory 'c:\your\workspace\'

But, as you've seen, it's not that useful - all it does is create a file called Launcher.exe in the target directory, which you can do yourself just as well.

I've uploaded the script that I use to create the ClickOnce files in my CI process, I'm sure there's room for improvement but it seems to do the trick:

https://github.com/alansingfield/ClickOncePowershell

@EPilyaev
Copy link

Hello! Thank you very much for the info provided here.
I faced the same situation as you but with update from .Net 4.7.2 amd64 ClickOnce to .Net 6.

Tried the approach from your first comment as a POC on a simple console net6 x64 app with a custom Launcher and dotnet mage 6, and that worked!

Will check auto update for my case now using this approach. Hope, it will work too.

P.S. It would be really great if we could specify the target processor architecture for Launcher using dotnet mage:

dotnet mage -al myapp.exe -td files -p amd64
dotnet mage -al myapp.exe -td files -p x86

@EPilyaev
Copy link

EPilyaev commented Feb 2, 2022

Upd. Managed to configure auto update for amd64 processor architecture from net472 to net6 pretty much the same way you have done it for x86 for net5.
Confirming that this approach works for net6 update too.
Thanks again for the info.

@nuzolx
Copy link

nuzolx commented Oct 19, 2023

Same as dotnet/sdk#32445
no?

@NikolaMilosavljevic did you plan to do something? Thx u.

@NikolaMilosavljevic
Copy link
Member

Same as dotnet/sdk#32445 no?

@NikolaMilosavljevic did you plan to do something? Thx u.

Launcher's architecture is MSIL. It does complicate direct upgrade from a version of application that is based on .NET FX (and uses architecture other than MSIL) to a modernized, .NET version of the app. There are currently no plans to provide various arch-specific versions of the launcher.

@NikolaMilosavljevic
Copy link
Member

Closing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants