AppImageTool会发出“找不到桌面文件”的警告

前端开发 2026-07-08

我为基于Linux的操作系统开发了一个桌面应用程序,我希望将其打包成AppImage,使用AppImageTool。在执行 appimagetool io.github.username.appname.AppDir/ 命令时,在AppStream验证检查过程中我看到以下警告,这会使打包过程终止:

io.github.username.appname.appdata.xml  
W: io.github.username.appname:~: desktop-file-not-found

然而,当我手动运行AppStream验证,使用 appstreamcli validate io.github.username.appname.AppDir/usr/share/metainfo/io.github.username.appname.appdata.xml 命令时,没有产生任何警告,验证通过。

AppImageTool版本:持续构建(git版本8c8c91f),构建296,构建时间为2025-12-04 17:55:56 UTC

AppStream版本:1.0.5

我使用的AppDir目录结构:

io.github.username.appname.AppDir
├── AppRun
├── icon.png
├── io.github.username.appname.desktop -> <path_to_AppDir>/io.github.username.appname.AppDir/usr/share/applications/io.github.username.appname.desktop
└── usr
    ├── bin
    │   └── AppName
    └── share
        ├── applications
        │   └── io.github.username.appname.desktop
        ├── icons
        │   └── hicolor
        │       └── 256x256
        │           └── apps
        │               └── icon.png
        └── metainfo
            └── io.github.username.appname.appdata.xml

io.github.username.appname.desktop 的内容:

[Desktop Entry]
Name=AppName
Comment=Short description
Exec=AppName
Icon=icon
Type=Application
Categories=Utility
StartupWMClass=AppName

io.github.username.appname.appdata.xml 的内容:

<?xml version="1.0" encoding="UTF-8"?>
<component type="desktop-application">
    <id>io.github.username.appname</id>
    <metadata_license>FSFAP</metadata_license>
    <project_license>GPL-3.0</project_license>
    <name>AppName</name>
    <icon type="remote" width="256" height="256">https://github.com/username/appname/blob/main/assets/logo.png?raw=true</icon>
    <summary>...</summary>
    <description>
        <p>...</p>
    </description>
    <categories>
                <category>Utility</category>
        </categories>
        <keywords>
                <keyword>project</keyword>
                <keyword>productivity</keyword>
        </keywords>
    <launchable type="desktop-id">io.github.username.appname</launchable>
    <url type="homepage">https://github.com/username/appname</url>
    <url type="bugtracker">https://github.com/username/appname/issues</url>
    <url type="vcs-browser">https://github.com/username/appname</url>
    <content_rating type="oars-1.0" />
    <developer id="io.github.username">
            <name>...</name>
    </developer>
</component>

AppRun 的内容:

#!/bin/sh

HERE="$(dirname "$(readlink -f "${0}")")"
EXEC="${HERE}/usr/bin/AppName"
exec "${EXEC}"

我尝试了以下方法:

  • 确保 AppRunusr/bin/AppName 具有可执行权限
  • 清理AppStream缓存后再次运行AppImageTool:

bash rm -rf /tmp/appstream-* rm -rf ~/.cache/appstream/ sudo rm -rf /var/tmp/appstream-* appimagetool io.github.username.appname.AppDir/ - 使用 --verbose 标志运行AppImageTool命令(没有提供关于验证失败的额外信息) - 确保 metainfo 目录和 io.github.username.appname.appdata.xml 的所有权正确:

bash chmod 644 io.github.username.appname.AppDir/usr/share/metainfo/io.github.username.appname.appdata.xml chmod 755 io.github.username.appname.AppDir/usr/share/metainfo/ - 查阅 这个问题 但我已经具备答案中描述的目录结构。

为什么AppImageTool命令的验证步骤会失败?我该如何让它通过?

解决方案

好吧,我找到了问题,似乎需要在应用程序ID之后,在 appdata.xml 文件中的 <id><launchable> 标签内添加.desktop。

站内所有文章版权归属LeftHeroAI导航站,无授权禁止任何主体转载、抄袭、复制内容,亦不得私自架设镜像站点。一经侵权,本站将通过法律途径追责。

相关文章