【问题标题】:Why Wix MSI doesn't include the source files and looks for source files somewhere else?为什么 Wix MSI 不包含源文件并在其他地方查找源文件?
【发布时间】:2014-11-09 02:26:24
【问题描述】:

我已经断断续续地使用 Wix 快一年了。稍作休息后,现在我回到了 wix,需要再次构建一个 wix Msi,但我发现了一个我以前从未遇到过的非常奇怪的事情。在我创建了 msi 文件并将 msi 复制到某个地方进行安装之后。在安装过程中,它显示一个错误,它无法从文件夹中找到源文件:当前 msi 位置\EasyLobby\Cogito。我想知道为什么它试图从那个位置找到源文件。然后我在编译过程中从项目中发现,它总是在 bin\Debug 文件夹下创建 \EasyLobby\Cogito。因此,如果我直接从 ...bin\Debug 运行 msi,它运行正常,因为 \EasyLobby\Cogito 文件夹在那里。 \

看起来很奇怪。 msi 文件应包含所有源文件,不应在其他地方查找源文件。这是 product.wxs 文件:

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">

<Product Id="*" Name="SetupCogito" Language="1033" Version="2.0.0.0" Manufacturer="Microsoft" UpgradeCode="96cb03c9-6a03-4344-b816-20a0bb9e5df0">
<Package InstallerVersion="200" Compressed="no" InstallScope="perMachine" />

<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<Media Id="1" Cabinet="Server.cab" EmbedCab="yes" />
<!--<MediaTemplate />-->

<Feature Id="ProductFeature" Title="SetupCogito" Level="1">
  <ComponentGroupRef Id="ComponentGroup"/>
  <ComponentRef Id="EasyLobbyCogitoShortcut" />
</Feature>
<WixVariable Id="WixUILicenseRtf" Value="Files\LicenseAgmt.rtf"/>

<UIRef Id="CogitoUI_Installdir" />

<Property Id="WIXUI_INSTALLDIR" Value="COGITOFOLDER" />
<Binary Id="banner_bmp" SourceFile="Files\Banner.bmp"/>
<Property Id ="PIDTemplate" >
  <![CDATA[&&&-&&&&&&-&&&&-&&&&]]>
</Property>

<Icon Id="ELCogitoConfig.exe" SourceFile="..\CogitoIntegration\ELCogitoConfig.exe" />
  </Product>

<Fragment>
<Binary Id="CustomActions"
       SourceFile="..\CustomActions\bin\Debug\CustomActions.CA.dll" />

   <CustomAction Id="IsValidKeyCode"
              BinaryKey="CustomActions"
              DllEntry="IsValidKeyCode"
              Execute="immediate"
              Return="check" />    
   <InstallExecuteSequence>
   <Custom Action="IsValidKeyCode"
        Before='InstallFinalize'>NOT Installed</Custom>
   </InstallExecuteSequence>

   </Fragment>


  <Fragment>
  <Directory Id="TARGETDIR" Name="SourceDir">
  <Directory Id="ProgramFilesFolder">
    <Directory Id="INSTALLFOLDER" Name="EasyLobby" >
      <Directory Id="COGITOFOLDER" Name="Cogito"/>
    </Directory>
  </Directory>

 <Directory Id="ProgramMenuFolder">
    <Directory Id="ApplicationProgramsFolder" Name="EasyLobby Cogito" />
  </Directory>

</Directory>
</Fragment>

<Fragment>
 <DirectoryRef Id="COGITOFOLDER">
  <Component Id="EasyLobbyCogitoShortcut" Guid="{BFE6EB30-0F71-4F92-8D93-84B4EBF41F0E}" >
    <File Id="Easy" Source="$(var.SourceDir)\ELCogitoConfig.exe" />
    <Shortcut Id="ApplicationStartMenuShortcut"  Name="Cogito Configuration"    Directory="ApplicationProgramsFolder"
      WorkingDirectory='INSTALLDIR' Icon="ELCogitoConfig.exe" IconIndex="0" Advertise="yes"/>
  </Component>
 </DirectoryRef>

这是项目文件中的热量配置:

<Target Name="BeforeBuild">
<PropertyGroup>
  <DefineConstants>SourceDir= C:\Development\SetupCogito\CogitoIntegration;</DefineConstants>
  <LinkerBaseInputPaths>..\CogitoIntegration\</LinkerBaseInputPaths>
</PropertyGroup>
<HeatDirectory OutputFile="CogitoSetup.wxs" Directory="..\CogitoIntegration" PreprocessorVariable="var.SourceDir" DirectoryRefId="COGITOFOLDER" ComponentGroupName="ComponentGroup" SuppressCom="true" SuppressFragments="true" SuppressRegistry="true" SuppressRootDirectory="true" AutoGenerateGuids="false" GenerateGuidsNow="true" ToolPath="$(WixToolPath)" />

【问题讨论】:

    标签: wix


    【解决方案1】:

    这行是你的问题:

    <Package InstallerVersion="200" Compressed="no" InstallScope="perMachine" />
    

    Compressed=no 更改为Compressed=yes,它将包含完成的MSI 中的所有源文件。如果不压缩,完成的文件不会包含在 MSI 中,如果在运行时找不到它们,则会出现错误。

    Package reference

    【讨论】:

    • 非常感谢。做到了!不知道为什么它是NO。一件简单的事情花了我几个小时,但你救了我!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多