question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Not working with /p:PublishSingleFile=true apps

See original GitHub issue

If a project is built as a single file:

dotnet publish -c Release -r win-x86 /p:PublishSingleFile=true
zip -j $zip_file ./bin/Release/netcoreapp3.1/win-x86/publish/myapp.exe

then the app is not updated with this code:

using (var manager = new UpdateManager(
	new WebPackageResolver(Config.update_manifest_url),
	new ZipPackageExtractor()))
{
	var result = await manager.CheckForUpdatesAsync();
	if (result.CanUpdate)
	{
		// Prepare an update by downloading and extracting the package
		// (supports progress reporting and cancellation)
		await manager.PrepareUpdateAsync(result.LastVersion);

		// Launch an executable that will apply the update
		// (can be instructed to restart the application afterwards)
		manager.LaunchUpdater(result.LastVersion);

		// Terminate the running application so that the updater can overwrite files
		Environment.Exit(0);
	}
}

It correctly detects the new version, downloads it, runs LaunchUpdater, but the actual file is not replaced with the new version. It works fine without /p:PublishSingleFile=true.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:54 (32 by maintainers)

github_iconTop GitHub Comments

2reactions
levitatejaycommented, Apr 25, 2020

Still can’t reproduce this on my end 😦 Could any of you provide a minimal repro project that exhibits the problem?

https://github.com/levitatejay/self-contained-update-stuck

Steps to reproduce:

  1. Create a 1.0.0.0 self contained exe
  2. Create a 2.0.0.0 self contained exe, zip it and place it as “c:/UpdateTest/Packages/SelfContainedUpdate-v2.0.0.0.zip”
  3. Run v1 and select “Yes”

The SelfContainedUpdate.exe closes itself and if you try to delete it says its in use by Onova The Onova process never closes

I think it is getting stuck here: https://github.com/Tyrrrz/Onova/blob/master/Onova.Updater/Updater.cs#L39

I need to see why the Updater doesn’t have Write Access even though the exe not running anymore

1reaction
elestedtcommented, Sep 27, 2020

@Tyrrrz I ran into this problem on my project and

var manager = new UpdateManager(
    AssemblyMetadata.FromAssembly(
        Assembly.GetEntryAssembly(), 
        System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName),
    new GithubPackageResolver("ipocsmr", "ipocs.dpt", "*" + os + "*"),
    new ZipPackageExtractor());

solved it for me. I backported the fix to an older version (by removing a couple of tags locally) and the update replaced the file - which it did not do before. Project can be found at https://github.com/ipocsmr/ipocs.dpt The fix will be included in version 4.0.2 onwards to see if it works when it hits the wild.

Read more comments on GitHub >

github_iconTop Results From Across the Web

PublishSingleFile does not produce a single executable
I have a .Net Core 3 console application that i'm trying to publish as a self contained single executable. I've been able to...
Read more >
dotnet/maui - publish failed with PublishSingleFile=true
I created a app by using the default template and test if it can be packaged as a SingleFile by using PublishSingleFile=true. But...
Read more >
Self-Contained Single-File does not produce a single file
I have a small .Net 5 console application with no dependencies on third party components. I have set it up to publish as...
Read more >
Create a single file for application deployment - .NET
Publish a single file application using the dotnet publish command. Add <PublishSingleFile>true</PublishSingleFile> to your project file. This ...
Read more >
Single File Apps In .NET 6 - NET Core Tutorials
The main issues were : The single file exe was actually a self extracting zip that unzipped to a temp location and then...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found