Onova: Not working with /p:PublishSingleFile=true apps

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.

About this issue

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

Commits related to this issue

Most upvoted comments

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

@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.

Update: the fix to the self-contained problem will come in the next .NET update:

https://github.com/dotnet/runtime/issues/13943#issuecomment-626191085