应用程序注册失败 (MAUI/Comet)

Registration on the app failed (MAUI/Comet)

代码:https://github.com/ToadallyAwesome2/ComettTest

所以我正在使用 Maui/Comet。我只想 运行 一个示例项目,但出现此错误:

DEP0700: Registration of the app failed. [0x80073CF6] 
AppxManifest.xml(33,27): error 0x80070003: Cannot install or update 
package BF12F2F8-C129-4401-821A-69268F23ED72_9zz4h110yvjzm because the
 splash screen image [appiconfgSplashScreen.png] cannot be located. 
Verify that the package contains an image that can be used as a splash
 screen for the application, and that the package manifest points to 
the correct location in the package where this splash screen image can
 be found.

有人知道我能做什么吗?我尝试用那个 png 制作一个资产文件夹,但它没有用。

更新 按照 Gerard Versluis 的建议进行操作并得到以下错误:

DEP0700: Registration of the app failed. [0x80080204] error 0xC00CE020:
 App manifest validation error: The app manifest must be valid as per 
schema: Line 26, Column 8, Reason: Het vereiste kenmerk 
Square150x150Logo ontbreekt.    CometApp1           

翻译:缺少必需的属性 Square150x150Logo。 我注意到它一直要求 Square150x150Logo

发生这种情况是因为其中一个预览发生了变化。长话短说;我们曾经有一个用于 Windows 应用程序的资产文件夹,但现在没有了。由于它全部处于预览状态,因此无需担心向后兼容性,但现在可能会发生这种情况。

发生这种情况是因为您可能较早开始了一个项目,使用的是较旧的模板,现在正在尝试针对新的预览位进行构建。所以在模板中仍然提到了 Assets 文件夹,但已经不存在了。

preview 13 migration guide 中也描述了要采取的步骤。

  1. 进入Platforms\Windows文件夹并打开Package.appxmanifest文件。 Right-click > 打开方式...并选择 XML 编辑器
  2. 删除对 Assets\
  3. 的所有引用
  4. Double-check 你的 App.xaml 文件,看看 Application 节点上是否有 windows:Application.ImageDirectory 属性。如果是这样,请将其删除。例如:
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:windows="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.WindowsSpecific;assembly=Microsoft.Maui.Controls"
             windows:Application.ImageDirectory="Assets"
             x:Class="WeatherTwentyOne.App">

现在应该是

<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="WeatherTwentyOne.App">

之后,它应该又可以工作了!

为确保不再发生这种情况,请确保您拥有 运行 dotnet new -i Microsoft.Maui.Templates 提供的最新模板,这应该会为您提供未引用 Assets 的最新模板不再。

这是唯一对我有用的解决方案: https://developercommunity.visualstudio.com/t/mauiapp-cannot-run-on-windows/1670999
粘贴在下面:

使用 升级 maui 模板 dotnet new --install Microsoft.Maui.Templates::6.0.200-preview.13.2865 在创建新的 MAUI 应用程序时解决了这个问题。

如果升级 VS 的过程可以包括更新 MAUI 模板或者警告需要手动更新,那就太好了

如果是现有的 MAUI 应用程序项目 - 这些更改对我有用:

  • 从 Platforms\Windows\Package.appxmanifest 文件中删除对“Assets”子文件夹的所有引用

  • 在包含 MauiIcon、MauiSplashScreen、MauiImage、MauiFont 标签的 ItemGroup 中的 .csproj 文件中添加一行关于原始资产的内容:

    <ItemGroup>
       ...
       <!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
       <MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
     </ItemGroup>
    

删除您的 .vs/obj/bin/.csproj/.sln,然后在同一个文件夹中删除 dotnet new maui --force。这为我解决了这个问题,这是随机发生的,但我认为这是由于我更新了一些工作负载。我还确定我的项目模板仍在预览 9 大声笑。每次预览都最好使用最新模板。

编辑:如果您修改了您的 App.xaml/App.xaml.cs and/or MainPage.xaml/MainPage.xaml.cs,您将需要保存它们,以便你可以把它们放回去。 dotnet new maui 需要覆盖一些东西。除非你删除它们,但它们只是模板生成的东西。您修改过的任何生成的内容都需要保存和更新。