使用wix创建msi

时间:2013-02-22 06:17:49

标签: wix

我正在开发一个wix代码来创建一个msi。我已将所有组件和库添加到我的wix项目中。但是,我无法根据需要创建一个msi。请帮帮我。这是我的代码,

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

<Product Name='SmartViewer'
          Id="*"
          Language='1033'
          Codepage='1252'
          Version='1.0.0'
          UpgradeCode='9C5E4073-EFDE-419B-935D-CE2632BC560E'>

    <Package Keywords='Installer,MSI'
             InstallerVersion='100'
             Languages='1031'
             Compressed='yes'
             SummaryCodepage='1252' />

    <Media Id="1" Cabinet="myapp.cab" EmbedCab="yes" />

    <Directory Id="TARGETDIR" Name="SourceDir">
        <Directory Id="ProgramFilesFolder">
            <Directory Id="MyProgramDir" Name="myproject" >
                <Directory Id="INSTALLFOLDER" Name="proj1" />
            </Directory>
        </Directory>

    <DirectoryRef Id="INSTALLFOLDER">
        <Component Id='MainExecutable' Guid='*'>
            <File Id='ExecutableFile' Name='mv.exe' DiskId='1' Source='mv.exe' KeyPath='yes'/>
        </Component>
        <Directory Id="imageformats" Name="imageformats">
            <Component Id='jpeg4Library' Guid='*'>
                <File Id='jpeg4' Name='jpeg4.dll' DiskId='1' Source='jpeg4.dll' KeyPath='yes' />
            </Component>
        </Directory>

        <Component Id='Network4Library' Guid='*'>
            <File Id='Network4' Name='Network4.dll' DiskId='1' Source='Network4.dll' KeyPath='yes' />
        </Component>

        <Component Id='Multimedia4Library' Guid='*'>
            <File Id='Multimedia4' Name='Multimedia4.dll' DiskId='1' Source='Multimedia4.dll' KeyPath='yes' />
        </Component>

        <Component Id='QtGui4Library' Guid='*'>
            <File Id='Gui4' Name='Gui4.dll' DiskId='1' Source='Gui4.dll' KeyPath='yes' />
        </Component>

        <Component Id='Designer4Library' Guid='*'>
            <File Id='Designer4' Name='Designer4.dll' DiskId='1' Source='Designer4.dll' KeyPath='yes' />
        </Component>

        <Component Id='Core4Library' Guid='*'>
            <File Id='Core4' Name='Core4.dll' DiskId='1' Source='Core4.dll' KeyPath='yes' />
        </Component>


        <Component Id='libmfxsw32Library' Guid='*'>
            <File Id='libmfxsw32' Name='libmfxsw32.dll' DiskId='1' Source='libmfxsw32.dll' KeyPath='yes' />
        </Component>

        <Component Id='libiomp5mdLibrary' Guid='*'>
            <File Id='libiomp5md' Name='libiomp5md.dll' DiskId='1' Source='libiomp5md.dll' KeyPath='yes' />
        </Component>

        <Component Id='ippcore7.1Library' Guid='*'>
            <File Id='ippcore7.1' Name='ippcore-7.1.dll' DiskId='1' Source='ippcore-7.1.dll' KeyPath='yes' />
        </Component>

        <Component Id='ippccw77.1Library' Guid='*'>
            <File Id='ippccw77.1' Name='ippccw7-7.1.dll' DiskId='1' Source='ippccw7-7.1.dll' KeyPath='yes' />
        </Component>

        <Component Id='ippccv87.1Library' Guid='*'>
            <File Id='ippccv87.1' Name='ippccv8-7.1.dll' DiskId='1' Source='ippccv8-7.1.dll' KeyPath='yes' />
        </Component>

        <Component Id='ippccs87.1Library' Guid='*'>
            <File Id='ippccs87.1' Name='ippccs8-7.1.dll' DiskId='1' Source='ippccs8-7.1.dll' KeyPath='yes' />
        </Component>

        <Component Id='ippccp87.1Library' Guid='*'>
            <File Id='ippccp87.1' Name='ippccp8-7.1.dll' DiskId='1' Source='ippccp8-7.1.dll' KeyPath='yes' />
        </Component>

        <Component Id='ippccg97.1Library' Guid='*'>
            <File Id='ippccg97.1' Name='ippccg9-7.1.dll' DiskId='1' Source='ippccg9-7.1.dll' KeyPath='yes' />
        </Component>

        <Component Id='ippcc7.1Library' Guid='*'>
            <File Id='ippcc7.1' Name='ippcc-7.1.dll' DiskId='1' Source='ippcc-7.1.dll' KeyPath='yes' />
        </Component>

        <Component Id='EULALibrary' Guid='*'>
            <File Id='EULA' Name='EULA.rtf' DiskId='1' Source='EULA.rtf' KeyPath='yes' />
        </Component>
    </DirectoryRef> 


    <Directory Id="ProgramFilesFolder">
        <Directory Id="MyProgramDir" Name="myproj" >
                <Directory Id="INSTALLFOLDER" Name="proj1" /
                    <Component Id="TextFileComponent" Guid="*">
                        <File Id="TextFile" Name="Logs.txt" DiskId="1"
                              Source="Logs.txt" KeyPath="yes" />
                    </Component>
        </Directory>
    </Directory>

    <Directory Id="DesktopFolder">
        <Component Id="ExecutableFileShortcutComponent" Guid="*">
            <Shortcut Id="ExecutableFileShortcut" Name="smart viewer" 
                  Description="Shortcut To Executable File"
                  Target="[INSTALLFOLDER]mv.exe" />
    </Directory>

    <Directory Id="ProgramMenuFolder">
        <Directory Id="MyProgramDir" Name="myproj">
            <Component Id="ExecutableFileShortcutComponent" Guid="*">
                <Shortcut Id="ExecutableFileShortcut" Name="smart viewer"
                      Description="Shortcut To Executable File"
                      Target="[INSTALLFOLDER]mv.exe" />

        </Component>
     </Directory>

  </Product>
 </Wix>

组件没有获取dll路径。我尝试将路径传递给文件ID中的源代码,但我仍然发现同样的问题。找到一个好的建议。

2 个答案:

答案 0 :(得分:1)

您需要引用文件的完整路径:

<File Id="Microsoft.Practices.Unity"
      Name="jpeg4.dll"
      Source="$(var.BuildOutputDir)\jpeg4.dll" />

其中$(var.BuildOutputDir)是文件夹的完整路径。如果这些文件位于另一个引用项目的输出中,那么您可以使用$(var.OtherProject.TargetDir)

答案 1 :(得分:0)

您的文件不包含有效的XML。以下片段已被删除。

<Directory Id="ProgramFilesFolder">
    <Directory Id="MyProgramDir" Name="myproj" >
            <Directory Id="INSTALLFOLDER" Name="proj1" /
                <Component Id="TextFileComponent" Guid="*">
                    <File Id="TextFile" Name="Logs.txt" DiskId="1"
                          Source="Logs.txt" KeyPath="yes" />
                </Component>
    </Directory>
</Directory>

该行

            <Directory Id="INSTALLFOLDER" Name="proj1" /

应该是

            <Directory Id="INSTALLFOLDER" Name="proj1" >

缺少一个</Directory>。您还应该在两个位置添加</Component>。尝试在加载.WXS文件时指向无效XML的WiXEdit。

此外,您应添加<feature>