YehudaKremer / msix

Create Msix installer for flutter windows-build files.
https://pub.dev/packages/msix
MIT License
273 stars 64 forks source link

[FEATURE REQUEST] Reenable appinstaller for web #256

Open mjauernig opened 6 months ago

mjauernig commented 6 months ago

:speech_balloon: Description

I use successfull appinstaller on Windows 11 and Server 2022 (with a modified proceed from here)

I also installed another apps via appinstaller. Example MSIX Hero

On this blog their is also the following update

Update: August 5, 2022 – The fix to enable the ms-appinstaller protocol handler was rolled out to Windows 11 Insider Preview Build 25147 for the Dev Channel. We will provide updates on the availability of the fix when we have them.

Would be nice if the build process generates the appinstaller file. With the app_installer configuration i get no file. The result should be like:

<?xml version="1.0" encoding="utf-8"?>
<AppInstaller
    Uri="https://.../ypsi.appinstaller"
    Version="1.0.9.0" xmlns="http://schemas.microsoft.com/appx/appinstaller/2018">
    <MainPackage
        Name="..."
        Publisher="CN=... cert subject"
        Version="1.0.9.0"
        Uri="https://.../ypsi.msix"
        ProcessorArchitecture="x64" />
    <UpdateSettings>
        <OnLaunch
            HoursBetweenUpdateChecks="0"
            ShowPrompt="true"
            UpdateBlocksActivation="true" />
        <AutomaticBackgroundTask />
        <ForceUpdateFromAnyVersion>true</ForceUpdateFromAnyVersion>
    </UpdateSettings>
</AppInstaller>

:question: Platform

Window

aweinber commented 6 months ago

I think dart run msix:publish creates an app_installer file, but I don't think it supports arbitrary URIs - the file has a local URI (its path on the local machine), and the following sections would need to change to support arbitrary web endpoints.

configuration.dart

    dynamic installerYaml = yaml['app_installer'] ?? YamlMap();

    publishFolderPath =
        _args['publish-folder-path'] ?? installerYaml['publish_folder_path'];
    hoursBetweenUpdateChecks = int.parse(_args['hours-between-update-checks'] ??
        installerYaml['hours_between_update_checks']?.toString() ??
        '0');
    if (hoursBetweenUpdateChecks < 0) hoursBetweenUpdateChecks = 0;
    automaticBackgroundTask = _args.wasParsed('automatic-background-task') ||
        installerYaml['automatic_background_task']?.toString().toLowerCase() ==
            'true';
    updateBlocksActivation = _args.wasParsed('update-blocks-activation') ||
        installerYaml['update_blocks_activation']?.toString().toLowerCase() ==
            'true';
    showPrompt = _args.wasParsed('show-prompt') ||
        installerYaml['show_prompt']?.toString().toLowerCase() == 'true';
    forceUpdateFromAnyVersion =
        _args.wasParsed('force-update-from-any-version') ||
            installerYaml['force_update_from_any_version']
                    ?.toString()
                    .toLowerCase() ==
                'true';

app_installer.dart

  Future<void> generateAppInstaller() async {
    _logger.trace('generate app installer');

    String appInstallerContent = '''<?xml version="1.0" encoding="utf-8"?>
  <AppInstaller xmlns="http://schemas.microsoft.com/appx/appinstaller/2018"
    Uri="${_config.appInstallerPath}" Version="${_config.msixVersion}">
    <MainPackage Name="${_config.identityName}" Version="${_config.msixVersion}"
      Publisher="${const HtmlEscape().convert(_config.publisher!.replaceAll(' = ', '='))}"
      Uri="$_msixVersionPath"
      ProcessorArchitecture="${_config.architecture}" />
    <UpdateSettings>
      <OnLaunch HoursBetweenUpdateChecks="${_config.hoursBetweenUpdateChecks}" 
        UpdateBlocksActivation="${_config.updateBlocksActivation}" ShowPrompt="${_config.showPrompt}" />
        ${_config.automaticBackgroundTask ? '<AutomaticBackgroundTask />' : ''}
        ${_config.forceUpdateFromAnyVersion ? '<ForceUpdateFromAnyVersion>true</ForceUpdateFromAnyVersion>' : ''}
    </UpdateSettings>
  </AppInstaller>''';

@YehudaKremer is my understanding correct? I need this use case myself and would draft a PR to support arbitrary URI overrides if you think this is a reasonable approach. Thanks in advance - this package has been a lifesaver already