You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用.NET 9开发PSA时Appx清单无效的部署错误求助

问题:Print Support Application部署时出现清单无效错误

环境信息

  • .NET版本:9.0.300
  • Windows 11 SDK
  • 开发环境:VS Professional 17.14.2
  • 操作系统:Windows 11 Pro Version 10.0.26100

错误信息

DEP0700: Registration of the app failed. [0x80073CF6] Error 0x80080204: The package "617e6418-6847-4fa1-bec6-3a3668d09f6d_1.0.0.0_x86__g0j7nbxh9a4mw" cannot be registered due to the following error: The appx package manifest is invalid.

项目为空白UWP应用,相关文件内容如下:


Package.appxmanifest内容

<?xml version="1.0" encoding="utf-8"?>
<Package
  xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
  xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"
  xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
  xmlns:uap11="http://schemas.microsoft.com/appx/manifest/uap/windows10/11"
  xmlns:printsupport="http://schemas.microsoft.com/appx/manifest/printsupport/windows10"
  xmlns:printsupport2="http://schemas.microsoft.com/appx/manifest/printsupport/windows10/2"
  IgnorableNamespaces="uap mp printsupport printsupport2 uap11">

    <Identity
      Name="617e6418-6847-4fa1-bec6-3a3668d09f6d"
      Publisher="CN=patrick"
      Version="1.0.0.0" />

    <mp:PhoneIdentity
      PhoneProductId="617e6418-6847-4fa1-bec6-3a3668d09f6d"
      PhonePublisherId="00000000-0000-0000-0000-000000000000" />

    <Properties>
        <DisplayName>PrintingApp</DisplayName>
        <PublisherDisplayName>patrick</PublisherDisplayName>
        <Logo>Assets\StoreLogo.png</Logo>
    </Properties>

    <Dependencies>
        <TargetDeviceFamily Name="Windows.Universal"
            MinVersion="10.0.22000.0" MaxVersionTested="10.0.22621.0" />
    </Dependencies>

    <Resources>
        <Resource Language="x-generate" />
    </Resources>

    <Applications>
        <Application
          Id="App"
          Executable="$targetnametoken$.exe"
          EntryPoint="PrintingApp.App">
            <uap:VisualElements
              DisplayName="PrintingApp"
              Square150x150Logo="Assets\Square150x150Logo.png"
              Square44x44Logo="Assets\Square44x44Logo.png"
              Description="PrintingApp"
              BackgroundColor="transparent">
                <uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png" />
                <uap:SplashScreen Image="Assets\SplashScreen.png" />
            </uap:VisualElements>

            <Extensions>
                 <!--1. 虚拟打印机工作流--> 
                <printsupport2:Extension
                  Category="windows.printSupportVirtualPrinterWorkflow"
                  EntryPoint="PrintingApp.Tasks.PrintSupportWorkflowBackgroundTask"
                  uap11:SupportsMultipleInstances="true">
                    <printsupport2:PrintSupportVirtualPrinter
                      DisplayName="ms-resource://PRINTER_NAME1"
                      PrinterUri="contoso-psa:printer1"
                      PreferredInputFormat="application/postscript"
                      OutputFileTypes="ps;pdf"
                      PdcFile="Config\PRINTER_PDC1.xml">
                        <printsupport2:SupportedFormats>
                            <printsupport2:SupportedFormat Type="application/postscript" />
                            <printsupport2:SupportedFormat Type="application/pdf" MaxVersion="1.7" />
                        </printsupport2:SupportedFormats>
                    </printsupport2:PrintSupportVirtualPrinter>
                </printsupport2:Extension>

                 <!--2. 打印支持扩展--> 
                <printsupport:Extension
                  Category="windows.printSupportExtension"
                  EntryPoint="PrintingApp.Tasks.PrintSupportExtensionBackgroundTask"
                  uap11:SupportsMultipleInstances="true" />

                 <!--3. 打印支持设置UI--> 
                <printsupport:Extension
                  Category="windows.printSupportSettingsUI"
                  EntryPoint="PrintingApp.Tasks.PrintSupportSettingsUIBackgroundTask"
                  uap11:SupportsMultipleInstances="true" />

                 <!--4. 打印支持作业UI--> 
                <printsupport:Extension
                  Category="windows.printSupportJobUI"
                  EntryPoint="PrintingApp.Tasks.PrintSupportJobUIBackgroundTask"
                  uap11:SupportsMultipleInstances="true" />
            </Extensions>
        </Application>
    </Applications>

    <Capabilities>
        <Capability Name="internetClient" />
    </Capabilities>
</Package>

入口类示例(其他类结构一致)

using Windows.ApplicationModel.Background;
using Windows.Graphics.Printing.PrintSupport;

namespace PrintingApp.Tasks
{
    /// <summary>
    /// 用于PrintTicket验证和扩展的后台任务
    /// </summary>
    public sealed partial class PrintSupportExtensionBackgroundTask : IBackgroundTask
    {
        public void Run(IBackgroundTaskInstance taskInstance)
        {
            var deferral = taskInstance.GetDeferral();


            deferral.Complete();
        }
    }
}

PRINTER_PDC1.xml内容(已设置为始终复制)

<?xml version="1.0" encoding="UTF-8"?>
<!--
  虚拟打印机(PSA)的PDC(打印设备功能)示例。
  命名空间psk代表PrintSchemaKernel(参见架构定义)。
-->
<psk:PrintDeviceCapabilities
    xmlns:psk="http://schemas.microsoft.com/windows/2003/08/printing/printschemakernel"
    psk:Version="1.0">

    <!-- 功能:PageMediaSize(纸张格式) -->
    <psk:Feature psk:Name="PageMediaSize">
        <psk:Option psk:Name="ISOA4">
            <psk:DisplayName xml:lang="en">A4</psk:DisplayName>
        </psk:Option>
        <psk:Option psk:Name="ISOB5">
            <psk:DisplayName xml:lang="en">B5</psk:DisplayName>
        </psk:Option>
        <psk:Option psk:Name="Letter">
            <psk:DisplayName xml:lang="en">Letter</psk:DisplayName>
        </psk:Option>
    </psk:Feature>

    <!-- 功能:PageOrientation(打印方向) -->
    <psk:Feature psk:Name="PageOrientation">
        <psk:Option psk:Name="Portrait">
            <psk:DisplayName xml:lang="en">纵向</psk:DisplayName>
        </psk:Option>
        <psk:Option psk:Name="Landscape">
            <psk:DisplayName xml:lang="en">横向</psk:DisplayName>
        </psk:Option>
    </psk:Feature>

    <!-- 功能:PageOutputColor(颜色输出) -->
    <psk:Feature psk:Name="PageOutputColor">
        <psk:Option psk:Name="Color">
            <psk:DisplayName xml:lang="en">彩色</psk:DisplayName>
        </psk:Option>
        <psk:Option psk:Name="Monochrome">
            <psk:DisplayName xml:lang="en">黑白</psk:DisplayName>
        </psk:Option>
    </psk:Feature>

    <!-- 功能:Duplex(双面打印) -->
    <psk:Feature psk:Name="Duplex">
        <psk:Option psk:Name="OneSided">
            <psk:DisplayName xml:lang="en">单面</psk:DisplayName>
        </psk:Option>
        <psk:Option psk:Name="TwoSidedLongEdge">
            <psk:DisplayName xml:lang="en">双面(长边翻转)</psk:DisplayName>
        </psk:Option>
        <psk:Option psk:Name="TwoSidedShortEdge">
            <psk:DisplayName xml:lang="en">双面(短边翻转)</psk:DisplayName>
        </psk:Option>
    </psk:Feature>

    <!-- 功能:Copies(打印份数) -->
    <psk:Feature psk:Name="Copies">
        <psk:Option psk:Name="CopiesSupported"/>
    </psk:Feature>

</psk:PrintDeviceCapabilities>

排查方向

  • 检查资源引用:ms-resource://PRINTER_NAME1 必须在项目资源文件(如Resources.resw)中存在对应键PRINTER_NAME1,未定义会触发清单验证失败。
  • 确认PDC文件路径:确保Config\PRINTER_PDC1.xml存在于项目Config目录,属性设为“始终复制到输出目录”,可尝试将路径分隔符改为/(即Config/PRINTER_PDC1.xml)。
  • 验证命名空间兼容性:printsupport2命名空间适配Windows 10 2004及以上版本,当前TargetDeviceFamily最小版本为10.0.22000.0(Windows 11)符合要求,需确认命名空间拼写无错误。
  • 确认后台任务类完整性:清单中声明的所有EntryPoint对应的类(如PrintSupportWorkflowBackgroundTask等)必须存在,且正确实现IBackgroundTask接口,命名空间和类名需与清单完全匹配。
  • 使用VS内置验证工具:右键Package.appxmanifest选择“查看代码”,通过菜单栏“生成”->“验证应用程序包”获取详细错误,定位具体无效项。
  • 核对Publisher信息:清单中Publisher值CN=patrick需与开发证书的Publisher一致,可在项目属性->打包->证书选项中确认,不一致会导致注册失败。

内容的提问来源于stack exchange,提问作者user1550946

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.12 23:18:10