MAUI ClickOnce app not auto-updating on launch

89 Views Asked by At

I'm trying to get ClickOnce installation to work for MAUI on Windows, with auto-update being the most important reason to do so. It's for internal use only, and we'd like to deploy to a fileshare (like we've done successfully with WPF apps in the past).

To isolate any factors from the real app, I'm starting from the template MAUI app (with a minor tweak to show me the running version). I'm publishing using Visual Studio, with the .pubxml settings below, specifying to check for updates on launch, and tell it to copy the installation files when it finishes. I end up with a folder named something like "MauiAppPublishTest_1.8.13.0_Test" on the fileshare, which contains a .cer a .msix file, and a Dependencies folder with runtime installers.

Compared to the WPF ClickOnce published output I had gotten working, there's no top-level .application file indicating which is the current version to auto-update to, so I'm not surprised it's not working.

I'll install from the MSIX file, and it installs and runs fine, but then when I increment the version number and publish again, it never downloads an update.

I haven't been able to find any specific examples online of how to accomplish this. While I prove out this process, I'm signing with the self-signed key produced by Visual Studio, which I've trusted on my machine.

What am I doing wrong, and/or where is there an example showing how to publish a MAUI app with auto-update using ClickOnce?

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <PublishUrl>\\fileservername\SHARENAME\Apps\Dev\AppName\</PublishUrl>
    <PublishDir>bin\Release\net7.0-windows10.0.19041.0\publish\</PublishDir>
    <PublishProtocol>FileSystem</PublishProtocol>
    <RuntimeIdentifier>win10-x64</RuntimeIdentifier>
    <Platform>Any CPU</Platform>
    <Configuration>Release</Configuration>
    <TargetFramework>net7.0-windows10.0.19041.0</TargetFramework>
    <PublishSingleFile>false</PublishSingleFile>
    <PublishReadyToRun>false</PublishReadyToRun>
    <SelfContained>True</SelfContained>
    <PublishAppxPackage>true</PublishAppxPackage>
    <AppxPackageDir>bin\Release\net7.0-windows10.0.19041.0\appx\</AppxPackageDir>
  </PropertyGroup>
</Project>
1

There are 1 best solutions below

0
Valerio On

Visual studio is not generating properly the .appinstaller file , but it's supposed to be there. (you can find a few posts on stackoverflow regarding the topic like this one APP INSTALLER FILE not generated when publishing .Net Maui Application using MSIX)

I was able to make it work for my Maui App in the following way (hopefully it will work for you aswell):

  • Deploy the application as you have been doing selecting the auto update options from the publish wizards
  • Load the Published app folder (the test folder you were mentioning) to your ftp
  • Generate manually the .appinstaller file or use the microsoft tool to generate it automatically (https://learn.microsoft.com/en-us/windows/msix/toolkit/msix-toolkit-appinstallerfilebuilder)
  • Load the appinstaller to your ftp
  • Install the application via the .appinstaller
  • Everytime you release a new update , load the folder to the ftp and update manually the appinstaller that you have uploaded

Here is an example of an .appinstaller file formatted correctly (name the file YOURAPPNAME.appinstaller):

<?xml version="1.0" encoding="utf-8"?>
<AppInstaller
  Version="YOUR APP VERSION (0.0.0.1 for example)"
  Uri="http://yourhost/YOURAPPNAME.appinstaller"
 xmlns="http://schemas.microsoft.com/appx/appinstaller/2017/2">
  <MainPackage
    Name="APPLICATION GUID -> Check your app properties"
    Publisher="publisher details"
    Version="CURRENT APP VERSION"
    ProcessorArchitecture="x64"
    Uri="http://yourhost- pointing at your latest msix YourAppFolder_0.0.0.0_Test/YOURAPPMSIXFILE.msix" />
  <Dependencies>
    <Package
      Version="3000.934.1904.0"
      Uri="http://your host pointing at your dependencies YourAppFolder_0.0.0.0_Test/Dependencies/x64/Microsoft.WindowsAppRuntime.1.3.msix"
      Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US"
      ProcessorArchitecture="x64"
      Name="Microsoft.WindowsAppRuntime.1.3" />
  </Dependencies>
    <UpdateSettings>
        <OnLaunch 
            HoursBetweenUpdateChecks="0" />
        <AutomaticBackgroundTask />
    </UpdateSettings>
</AppInstaller>

If you generate the .appinstaller the first time via the microsoft tool is way easier , and then after each update you only have to modify the app version (and the dependencies if they change)

Don't expect too see the old clickonce update window appearing , the app will update in background on startup (sometimes in requires an additional restart)