问题:
如何获取 MSIXappinstaller
在每次构建/发布期间输出正确的设置?
Context:
这是一个后续问题启用侧面加载后,为什么 MSIX 不会在每次应用程序运行时自动检查更新? https://stackoverflow.com/q/67271306/4630376
我在跑步:
- Windows 10 20H2,操作系统内部版本 19042.928
- Visual Studio 2019 社区版,版本 16.9.4
MSIX Windows 目标设置如下:
- 目标版本 = Windows 10 版本 2004
- 最低版本 = Windows 10 版本 1809
MSIX 安装程序项目创建了无效的appinstaller
文件,这会阻止应用程序在每次运行时自动检查更新。我可以在每次构建/发布后手动更改文件,但我认为我不应该这样做,因为这似乎既弄巧成拙又错误。
一般来说,我几乎会忽略创建appinstaller
每次,但文件都会自动增加版本号。所以,我目前似乎陷入了某种形式的手动干预,要么改变schema version
and UpdateSettings
部分或更新路径中的版本。这可能与运行 Visual Studio Community 版本有关吗?我需要专业人士才能让它发挥作用吗?
Visual Studio 创建的 Appinstaller,这是错误的:
<?xml version="1.0" encoding="utf-8"?>
<AppInstaller
Uri="https://<AppService>.azurewebsites.net/<AppName>.Setup.appinstaller"
Version="<AppVersion>" xmlns="http://schemas.microsoft.com/appx/appinstaller/2017/2">
<MainBundle
Name="<SomeGuid>"
Version="<AppVersion>"
Publisher="CN=<CertificateName>"
Uri="https://<AppService>.azurewebsites.net/<AppName>.Setup_<AppVersion>_Development_Test/<AppName>.Setup_<AppVersion>_x64_Development.msixbundle" />
<UpdateSettings>
<OnLaunch
HoursBetweenUpdateChecks="0" />
</UpdateSettings>
</AppInstaller>
我需要 Visual Studio 创建的应用程序安装程序:
<?xml version="1.0" encoding="utf-8"?>
<AppInstaller
Uri="https://<AppService>.azurewebsites.net/<AppName>.Setup.appinstaller"
Version="<AppVersion>" xmlns="http://schemas.microsoft.com/appx/appinstaller/2018">
<MainBundle
Name="<SomeGuid>"
Version="<AppVersion>"
Publisher="<CertificateName>"
Uri="https://<AppService>.azurewebsites.net/<AppName>.Setup_<AppVersion>_Development_Test/<AppName>.Setup_<AppVersion>_x64_Development.msixbundle" />
<UpdateSettings>
<OnLaunch
HoursBetweenUpdateChecks="0"
ShowPrompt="true"
UpdateBlocksActivation="true" />
<AutomaticBackgroundTask />
<ForceUpdateFromAnyVersion>true</ForceUpdateFromAnyVersion>
</UpdateSettings>
</AppInstaller>
我们解决了即使启用了侧面加载,应用程序也不检查自动更新的问题。我们需要向应用程序安装程序类型的 MSIX 项目添加一个附加项。这将创建默认文件名 Package.appinstaller*。此文件提供 appinstaller 文件的配置设置,需要这些设置才能控制所有可用设置,包括 UpdateSettings 部分。
应用程序安装程序允许的一些附加功能是阻止用户在不更新的情况下运行应用程序。这是 ClickOnce 发布配置文件的一个问题,因为它为用户提供了跳过更新的选项;我们无法找到防止这种情况发生的方法。不过,MSIX 应用安装程序允许控制此行为。
*请勿重命名此文件,因为构建/发布实用程序不会选择它并将设置应用到 APPINSTALLER 文件。这似乎是一个错误/静态文件引用。
Package.appinstaller
<?xml version="1.0" encoding="utf-8"?>
<AppInstaller Uri="{AppInstallerUri}"
Version="{Version}"
xmlns="http://schemas.microsoft.com/appx/appinstaller/2018">
<MainBundle Name="{Name}"
Version="{Version}"
Publisher="{Publisher}"
Uri="{MainPackageUri}"/>
<UpdateSettings>
<OnLaunch
HoursBetweenUpdateChecks="0"
ShowPrompt="true"
UpdateBlocksActivation="true" />
<AutomaticBackgroundTask />
<ForceUpdateFromAnyVersion>true</ForceUpdateFromAnyVersion>
</UpdateSettings>
</AppInstaller>
参考:
- https://techcommunity.microsoft.com/t5/windows-dev-appconsult/handling-application-updates-with-app-installer-and-msix-in/ba-p/355389 https://techcommunity.microsoft.com/t5/windows-dev-appconsult/handling-application-updates-with-app-installer-and-msix-in/ba-p/355389
附加参考资料:
- http://thewindowsupdate.com/2019/02/22/handling-application-updates-with-app-installer-and-msix-in-windows-10-19h1/ http://thewindowsupdate.com/2019/02/22/handling-application-updates-with-app-installer-and-msix-in-windows-10-19h1/
- https://learn.microsoft.com/en-us/windows/msix/app-installer/update-settings https://learn.microsoft.com/en-us/windows/msix/app-installer/update-settings
- https://developercommunity.visualstudio.com/t/published-msixappx-does-not-check-for-updates-when/776276 https://developercommunity.visualstudio.com/t/published-msixappx-does-not-check-for-updates-when/776276
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)