快捷方式的图标

15

你能告诉我,我的代码有什么问题吗?

<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xse="http://schemas.microsoft.com/wix/2005/XmlSchemaExtension" xmlns:html="http://www.w3.org/1999/xhtml">
    <Product Id="c1ee1e1f-4e2a-41c6-a716-eb6f79477012" Name="AdministKOB" Language="1033" Version="1.0.0.0" Manufacturer="Project UP" UpgradeCode="909b9926-711d-4a97-887b-df0bafc6ea66">
        <Package InstallerVersion="200" Compressed="yes" />
        <Media Id="1" Cabinet="media1.cab" EmbedCab="yes" />

      <Icon Id="ikonka" SourceFile="Files\AdministKOB.exe"/>

      <Directory Id="TARGETDIR" Name="SourceDir">
          <Directory Id="DesktopFolder"/>
            <Directory Id="ProgramMenuFolder">
          </Directory>

          <Directory Id="ProgramFilesFolder">
                <Directory Id="INSTALLLOCATION" Name="Administ_KOB">
                    <Component Id="ProductComponent" Guid="6bd37582-5219-4ae4-a56e-cd1ecd375efa">
                      <File Id="AdministKOB" Name="AdministKOB.exe" Source="Files\AdministKOB.exe" KeyPath="yes">
                        <Shortcut Advertise="yes"
                                      Id="DesktopShortcut"
                                      Directory="DesktopFolder"
                                      Name="AdministKOB"
                                      WorkingDirectory="INSTALLDIR"
                                      Description="Elektroniczna ksiazka budynku"
                                      Icon ="ikonka">
                        </Shortcut>
                      </File>
                      <!--<File Id="ikonka" Name="C.ico" DiskId="1"  Source="City.ico" Vital="yes" />-->
                    </Component>
                </Directory>
            </Directory>
        </Directory>

        <Feature Id="ProductFeature" Title="AdministKOB" Level="1">
            <ComponentRef Id="ProductComponent" />
        </Feature>
        <Property Id="WIXUI_INSTALLDIR" Value="INSTALLLOCATION" />
    </Product>
</Wix>

我收到以下错误和警告信息:

快捷方式“DesktopShortcut”的图标“ikonka”的扩展名不是“exe”或“ico”。图标将无法正确显示。

为什么?我提供了ICO文件。

组件“ProductComponent”的密钥文件的扩展名与“DesktopShortcut”的图标“ikonka”的扩展名不匹配。

你有任何想法吗?

6个回答

18

你似乎缺少一个 Icon 元素。例如:

    <Icon Id="City.ico" SourceFile="City.ico" />
    <Component ...>
        <File ...>
            <Shortcut Advertise="yes"
                Id="DesktopShortcut"
                Directory="DesktopFolder"
                Name="AdministKOB"
                WorkingDirectory="INSTALLDIR"
                Description="Elektroniczna książka budynku"
                Icon ="City.ico" />
        </File>
    </Component>

2
当我在<Component>上方添加Icon元素时,会出现以下错误:“ComponentGroup元素包含意外的子元素'Icon'。” - MARKAND Bhatt
@MARKANDBhatt 它应该放在产品元素下面。 - JWiley

16

您的图标 ID 必须带有 ".exe" 或 ".ico" 的扩展名。

图标 ID="ikonka*.ico*" 源文件="Files\AdministKOB.exe"


7
这是WiX的一个非常愚蠢的要求。我已经尝试解决同样的问题两天了。感谢您提供的解决方案。 - J Pollack

4

很容易:

<Shortcut Directory="DesktopFolder" Id="DesktopShortcut" Name="YourApp" Description="DescriptionOfYourApp" Target="http://localhost/" Icon="YourAppIcon">
      <Icon Id="YourAppIcon" SourceFile="$(var.BinDir)\favicon.ico" />
</Shortcut>

1

我在我的列表顶部放置了标签 :) 我使用exe文件中的图标。Wix要求文件图标文件和我的文件(桌面上的快捷方式)具有相同的扩展名

感谢您的关注 :)


0

此外,快捷方式的图标属性可以直接使用exe或ico文件的路径,但是文件名中不能有任何空格,否则会出错:

The Shortcut/@Icon attribute's value, '"C:\Users\yadayadayada\Data Migration.exe', is not a 
legal identifier.  Identifiers may contain ASCII characters A-Z, a-z, digits, underscores 
(_), or periods (.).  Every identifier must begin with either a letter or an underscore.    
SetupProject    C:\Users\yadayadayada\SetupProject\Product.wxs  53

0

以下方法适用于我。可能因人而异。

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<Icon Id="dbwizard.ico" SourceFile="dbwizard.ico" />
<ComponentGroup Id="DBWizardComponentGroup" Directory="INSTALLFOLDER">
  <Component Id="FakeDBWizard_exe" Guid="{2008318F-8628-411E-B1B9-BC92989BCD19}">
    <File Id="FakeDBWizard_exe"
          Name="FakeDBWizard_exe"
          Source="database\FakeDBWizard.exe"
          KeyPath="yes">
      <Shortcut Id="DBWizardShortcut"
                Directory="Otter32ShortcutDir"
                Name="Otter Database Wizards"
                Description="Database Wizards for ABCSystem32"
                WorkingDirectory="INSTALLFOLDER"
                Advertise="yes"
                Icon="dbwizard.ico" />

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接