Wix 目录问题

发布于 2024-10-19 23:41:02 字数 5050 浏览 5 评论 0原文

我有两个关于在 Windows Installer XML 中使用片段的目录的问题。

我从 heat.exe 获得了这个片段文件:

    <?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Fragment>
        <DirectoryRef Id="TARGETDIR">
            <Directory Id="dir08A07F5561FBEB6B9772467C730F6445" Name="Test" />
        </DirectoryRef>
    </Fragment>
    <Fragment>
        <ComponentGroup Id="InstallationFiles">
            <Component Id="cmp071F7F8F6B6027C8D2841272FE526A2B" Directory="dir08A07F5561FBEB6B9772467C730F6445" Guid="{CCCB70AC-29F5-4DAA-B03E-1A2266649AB6}">
                <File Id="fil63087E96FFB31F9E39B642CE8914F48B" KeyPath="yes" Source="SourceDir\dmedv.jpg" />
            </Component>
            <Component Id="cmpAE6CBEDA75641CF25BA9996AEB74A0DE" Directory="dir08A07F5561FBEB6B9772467C730F6445" Guid="{F5DABCAB-95D1-4197-A49F-E5F052A8E7EF}">
                <File Id="filD27F2F6B26F5C14563865FE6C2AD5D50" KeyPath="yes" Source="SourceDir\Files.txt" />
            </Component>
            <Component Id="cmp25C5EADB5C0A9E779D20EC7B77BD42B0" Directory="dir08A07F5561FBEB6B9772467C730F6445" Guid="{E301B04A-6EA5-496B-A58A-8898110BE57C}">
                <File Id="fil7C91C48D9AA0F2FE0EB37A21F108037F" KeyPath="yes" Source="SourceDir\readme.txt" />
            </Component>
            <Component Id="cmpD387AB4B40EDF14BF271ADDA7B71D2B7" Directory="dir08A07F5561FBEB6B9772467C730F6445" Guid="{6AF61DF4-32D0-4E7C-95B8-1DB9E7409029}">
                <File Id="fil966691BA382AFC9343430FE162643432" KeyPath="yes" Source="SourceDir\readme1.txt" />
            </Component>
            <Component Id="cmpB86212407C1BEA12838C8C7B20495E9F" Directory="dir08A07F5561FBEB6B9772467C730F6445" Guid="{921E971E-E224-464C-9FBC-FBC5F78B3E5B}">
                <File Id="fil61CD8EF43EA29DF58454E9A19F8C1EF9" KeyPath="yes" Source="SourceDir\readme2.txt" />
            </Component>
            <Component Id="cmpE4143B48FF854AE84F6054D4636FDE81" Directory="dir0ADF7E89B935DD39670130B4DC1D670E" Guid="{6F248718-93DD-4850-A18E-BD7079F738D5}">
                <File Id="fil03847B355B6AADE5E4E04D143C92BC67" KeyPath="yes" Source="SourceDir\Test2\dmedv2.jpg" />
            </Component>
        </ComponentGroup>
    </Fragment>
    <Fragment>
        <DirectoryRef Id="dir08A07F5561FBEB6B9772467C730F6445" />
    </Fragment>
    <Fragment>
        <DirectoryRef Id="dir0ADF7E89B935DD39670130B4DC1D670E" />
    </Fragment>
    <Fragment>
        <DirectoryRef Id="dir08A07F5561FBEB6B9772467C730F6445">
            <Directory Id="dir0ADF7E89B935DD39670130B4DC1D670E" Name="Test2" />
        </DirectoryRef>
    </Fragment>
</Wix>

并且我有这个 wix 安装程序文件:

<?xml version='1.0' encoding='windows-1252'?>

<?define ProductVersion="1.0.0.0"?>
<?define ProductName="DMServices Installer"?>
<?define Manufacturer="DM EDV- und Bürosysteme GmbH"?>

<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'  xmlns:iis='http://schemas.microsoft.com/wix/IIsExtension'>
  <Product Name="$(var.ProductName)" Id='BB7FBBE4-0A25-4cc7-A39C-AC916B665220' UpgradeCode='8A5311DE-A125-418f-B0E1-5A30B9C667BD'
    Language='1033' Codepage='1252' Version="$(var.ProductVersion)" Manufacturer="$(var.Manufacturer)">

    <Package Id='*' Keywords='Installer'
      Description="DMService Installer Setup"
      Manufacturer='DM EDV- und Bürosysteme GmbH'
      InstallerVersion='100' Languages='1033' Compressed='yes' SummaryCodepage='1252' />

    <Media Id='1' Cabinet='Sample.cab' EmbedCab='yes' DiskPrompt="CD-ROM #1" />
    <Property Id='DiskPrompt' Value="the man" />

    <PropertyRef Id="NETFRAMEWORK35"/>
    <Condition Message='This setup requires the .NET Framework 3.5.'>
      <![CDATA[Installed OR (NETFRAMEWORK35)]]>
    </Condition>

   <Directory Id='TARGETDIR' Name='SourceDir'>
      <Directory Id='ProgramFilesFolder'>
        <Directory Id='DM' Name='DM EDV'>
          <Directory Id='INSTALLDIR' Name='DMServices'>
          </Directory>
        </Directory>
      </Directory>
   </Directory>

<Feature Id='InstallationFiles' Title='InstallationFiles' Level='1'>
      <ComponentGroupRef Id='InstallationFiles' />
    </Feature>

  </Product>
</Wix>

到目前为止。

现在,当我将此文件生成到 wixobj 时,编译器会显示错误,因为找不到这些文件。这些文件位于名为“Test”的目录中。在文件中它被命名为 SourceDir。

对于一个小解决方法,我可以复制测试目录并将其命名为 SourceDir ;-)。这样我的安装程序就会被创建。

  1. 如果没有第二个目录,我该如何做到这一点?
    • 编辑:问题已解决

现在我安装我的包。但无论我做什么,这些文件都会安装到 C:\Test。

但我希望它安装在我的程序文件目录中。

在很多例子中我都可以做到这一点,就像在文件中一样,但我必须知道指南。 但我们使用 wix 来从一个目录中获取所有文件,而无需亲自动手。

  1. 那么如何将文件安装到program files目录下呢?

I have two questions about the directories with using fragments in Windows Installer XML.

I got this fragment file from the heat.exe:

    <?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Fragment>
        <DirectoryRef Id="TARGETDIR">
            <Directory Id="dir08A07F5561FBEB6B9772467C730F6445" Name="Test" />
        </DirectoryRef>
    </Fragment>
    <Fragment>
        <ComponentGroup Id="InstallationFiles">
            <Component Id="cmp071F7F8F6B6027C8D2841272FE526A2B" Directory="dir08A07F5561FBEB6B9772467C730F6445" Guid="{CCCB70AC-29F5-4DAA-B03E-1A2266649AB6}">
                <File Id="fil63087E96FFB31F9E39B642CE8914F48B" KeyPath="yes" Source="SourceDir\dmedv.jpg" />
            </Component>
            <Component Id="cmpAE6CBEDA75641CF25BA9996AEB74A0DE" Directory="dir08A07F5561FBEB6B9772467C730F6445" Guid="{F5DABCAB-95D1-4197-A49F-E5F052A8E7EF}">
                <File Id="filD27F2F6B26F5C14563865FE6C2AD5D50" KeyPath="yes" Source="SourceDir\Files.txt" />
            </Component>
            <Component Id="cmp25C5EADB5C0A9E779D20EC7B77BD42B0" Directory="dir08A07F5561FBEB6B9772467C730F6445" Guid="{E301B04A-6EA5-496B-A58A-8898110BE57C}">
                <File Id="fil7C91C48D9AA0F2FE0EB37A21F108037F" KeyPath="yes" Source="SourceDir\readme.txt" />
            </Component>
            <Component Id="cmpD387AB4B40EDF14BF271ADDA7B71D2B7" Directory="dir08A07F5561FBEB6B9772467C730F6445" Guid="{6AF61DF4-32D0-4E7C-95B8-1DB9E7409029}">
                <File Id="fil966691BA382AFC9343430FE162643432" KeyPath="yes" Source="SourceDir\readme1.txt" />
            </Component>
            <Component Id="cmpB86212407C1BEA12838C8C7B20495E9F" Directory="dir08A07F5561FBEB6B9772467C730F6445" Guid="{921E971E-E224-464C-9FBC-FBC5F78B3E5B}">
                <File Id="fil61CD8EF43EA29DF58454E9A19F8C1EF9" KeyPath="yes" Source="SourceDir\readme2.txt" />
            </Component>
            <Component Id="cmpE4143B48FF854AE84F6054D4636FDE81" Directory="dir0ADF7E89B935DD39670130B4DC1D670E" Guid="{6F248718-93DD-4850-A18E-BD7079F738D5}">
                <File Id="fil03847B355B6AADE5E4E04D143C92BC67" KeyPath="yes" Source="SourceDir\Test2\dmedv2.jpg" />
            </Component>
        </ComponentGroup>
    </Fragment>
    <Fragment>
        <DirectoryRef Id="dir08A07F5561FBEB6B9772467C730F6445" />
    </Fragment>
    <Fragment>
        <DirectoryRef Id="dir0ADF7E89B935DD39670130B4DC1D670E" />
    </Fragment>
    <Fragment>
        <DirectoryRef Id="dir08A07F5561FBEB6B9772467C730F6445">
            <Directory Id="dir0ADF7E89B935DD39670130B4DC1D670E" Name="Test2" />
        </DirectoryRef>
    </Fragment>
</Wix>

and I have this wix installer file:

<?xml version='1.0' encoding='windows-1252'?>

<?define ProductVersion="1.0.0.0"?>
<?define ProductName="DMServices Installer"?>
<?define Manufacturer="DM EDV- und Bürosysteme GmbH"?>

<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'  xmlns:iis='http://schemas.microsoft.com/wix/IIsExtension'>
  <Product Name="$(var.ProductName)" Id='BB7FBBE4-0A25-4cc7-A39C-AC916B665220' UpgradeCode='8A5311DE-A125-418f-B0E1-5A30B9C667BD'
    Language='1033' Codepage='1252' Version="$(var.ProductVersion)" Manufacturer="$(var.Manufacturer)">

    <Package Id='*' Keywords='Installer'
      Description="DMService Installer Setup"
      Manufacturer='DM EDV- und Bürosysteme GmbH'
      InstallerVersion='100' Languages='1033' Compressed='yes' SummaryCodepage='1252' />

    <Media Id='1' Cabinet='Sample.cab' EmbedCab='yes' DiskPrompt="CD-ROM #1" />
    <Property Id='DiskPrompt' Value="the man" />

    <PropertyRef Id="NETFRAMEWORK35"/>
    <Condition Message='This setup requires the .NET Framework 3.5.'>
      <![CDATA[Installed OR (NETFRAMEWORK35)]]>
    </Condition>

   <Directory Id='TARGETDIR' Name='SourceDir'>
      <Directory Id='ProgramFilesFolder'>
        <Directory Id='DM' Name='DM EDV'>
          <Directory Id='INSTALLDIR' Name='DMServices'>
          </Directory>
        </Directory>
      </Directory>
   </Directory>

<Feature Id='InstallationFiles' Title='InstallationFiles' Level='1'>
      <ComponentGroupRef Id='InstallationFiles' />
    </Feature>

  </Product>
</Wix>

So far.

Now when i generate this files to wixobj, the compiler shows errors because the files can't be found. The files are in a directory called "Test". And in the file it's named SourceDir.

For a lil workaround i can copy the test directory and call it SourceDir ;-). So my Setup will be created.

  1. How can I do it without a second directory?
    • EDIT: Problem is done.

Now i install my package. But whatever i do, the files will be installed to C:\Test.

But I want it to be installed in my Program Files Directory.

In many examples i can do it, like in the file, but i have to know the guids.
But we do wix for getting all files from one directory, without to put our hands on.

  1. So how to install the files into the program files directory?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

雨落星ぅ辰 2024-10-26 23:41:02

仔细看看 heat.exe-dr 开关。您可以将必要的目录引用放在那里。因此,像现在一样在主文件中定义目录结构,并向 heat.exe 提供正确的目录 ID。

更新:

好的,以下内容对我有用。主目录结构:

  <Directory Id="TARGETDIR" Name="SourceDir">
     <Directory Id="INSTALLLOCATION" Name="My folder">
        <Directory Id="WebsiteFolder" Name="Website">
        ...
        </Directory>
     </Directory>
  </Directory>

该功能引用 ComponentGroup:

<Feature Id="ProductFeature" Title="!(loc.ProductFeature.Title)" Level="100">
     ...
     <ComponentGroupRef Id="WebsiteFolderComponentGroup"/>
     ...
  </Feature>

heat.exe 生成以下片段:

    <Fragment>
        <DirectoryRef Id="WebsiteFolder">
            <Component Id="cmp1" Guid="GUID-GOES-HERE">
                <File Id="fil1" KeyPath="yes" Source="$(var.WebsiteFolderSource)\Default.aspx" />
            </Component>
            <Component Id="cmp2" Guid="GUID-GOES-HERE">
                <File Id="fil2" KeyPath="yes" Source="$(var.WebsiteFolderSource)\default.css" />
            </Component>
            <Directory Id="dir1" Name="App_Browsers">
                <Component Id="cmp3" Guid="GUID-GOES-HERE">
                    <File Id="fil3" KeyPath="yes" Source="$(var.WebsiteFolderSource)\App_Browsers\Form.browser" />
                </Component>
            </Directory>
            <Directory Id="App_Config" Name="App_Config">
                <Component Id="cmp4" Guid="GUID-GOES-HERE">
                    <File Id="fil4" KeyPath="yes" Source="$(var.WebsiteFolderSource)\App_Config\ConnectionStrings.config" />
                </Component>
            </Directory>
            <Directory Id="bin" Name="bin">
                <Component Id="cmp5" Guid="GUID-GOES-HERE">
                    <File Id="fil5" KeyPath="yes" Source="$(var.WebsiteFolderSource)\bin\MySystem.Web.UI.dll" />
                </Component>
                <Component Id="cmp6" Guid="GUID-GOES-HERE">
                    <File Id="fil6" KeyPath="yes" Source="$(var.WebsiteFolderSource)\bin\Another.dll" />
                </Component>
              ...
            </Directory>
        ...
        </Directory>

...

        <ComponentGroup Id="WebsiteFolderComponentGroup">
            <ComponentRef Id="cmp1" />
            <ComponentRef Id="cmp2" />
            <ComponentRef Id="cmp3" />
            <ComponentRef Id="cmp4" />
            ...
        </ComponentGroup>

最后,生成必要输出的 heat 命令如下所示(Nant 示例):

  <exec program="heat.exe" verbose="true" basedir="${paths.source}">
     <arg line='dir "${paths.dist.website}"'/><!-- Notice the quotes inside the attributes -->
     <arg line='-srd'/>
     <arg line='-dr WebsiteFolder'/>
     <arg line='-cg WebsiteFolderComponentGroup'/>
     <arg line='-out "${paths.harvest}\website.wxs"'/>
     <arg line='-ke -sfrag -scom -sreg -gg'/>
     <arg line='-var var.WebsiteFolderSource'/>
  </exec>

这些片段包含足够的信息来了解其工作原理。使用 heat.exe 开关来找出您需要的组合。祝你好运!

Take a closer look at -dr switch of heat.exe. You can put the necessary directory reference there. So, define your directory structure in the main file as you do now, and provide correct directory ID to heat.exe.

UPDATE:

Ok, the following works for me. The main directory structure:

  <Directory Id="TARGETDIR" Name="SourceDir">
     <Directory Id="INSTALLLOCATION" Name="My folder">
        <Directory Id="WebsiteFolder" Name="Website">
        ...
        </Directory>
     </Directory>
  </Directory>

The Feature references the ComponentGroup:

<Feature Id="ProductFeature" Title="!(loc.ProductFeature.Title)" Level="100">
     ...
     <ComponentGroupRef Id="WebsiteFolderComponentGroup"/>
     ...
  </Feature>

The heat.exe generates the following fragment:

    <Fragment>
        <DirectoryRef Id="WebsiteFolder">
            <Component Id="cmp1" Guid="GUID-GOES-HERE">
                <File Id="fil1" KeyPath="yes" Source="$(var.WebsiteFolderSource)\Default.aspx" />
            </Component>
            <Component Id="cmp2" Guid="GUID-GOES-HERE">
                <File Id="fil2" KeyPath="yes" Source="$(var.WebsiteFolderSource)\default.css" />
            </Component>
            <Directory Id="dir1" Name="App_Browsers">
                <Component Id="cmp3" Guid="GUID-GOES-HERE">
                    <File Id="fil3" KeyPath="yes" Source="$(var.WebsiteFolderSource)\App_Browsers\Form.browser" />
                </Component>
            </Directory>
            <Directory Id="App_Config" Name="App_Config">
                <Component Id="cmp4" Guid="GUID-GOES-HERE">
                    <File Id="fil4" KeyPath="yes" Source="$(var.WebsiteFolderSource)\App_Config\ConnectionStrings.config" />
                </Component>
            </Directory>
            <Directory Id="bin" Name="bin">
                <Component Id="cmp5" Guid="GUID-GOES-HERE">
                    <File Id="fil5" KeyPath="yes" Source="$(var.WebsiteFolderSource)\bin\MySystem.Web.UI.dll" />
                </Component>
                <Component Id="cmp6" Guid="GUID-GOES-HERE">
                    <File Id="fil6" KeyPath="yes" Source="$(var.WebsiteFolderSource)\bin\Another.dll" />
                </Component>
              ...
            </Directory>
        ...
        </Directory>

...

        <ComponentGroup Id="WebsiteFolderComponentGroup">
            <ComponentRef Id="cmp1" />
            <ComponentRef Id="cmp2" />
            <ComponentRef Id="cmp3" />
            <ComponentRef Id="cmp4" />
            ...
        </ComponentGroup>

And finally, the heat command which generates necessary output looks like this (Nant sample):

  <exec program="heat.exe" verbose="true" basedir="${paths.source}">
     <arg line='dir "${paths.dist.website}"'/><!-- Notice the quotes inside the attributes -->
     <arg line='-srd'/>
     <arg line='-dr WebsiteFolder'/>
     <arg line='-cg WebsiteFolderComponentGroup'/>
     <arg line='-out "${paths.harvest}\website.wxs"'/>
     <arg line='-ke -sfrag -scom -sreg -gg'/>
     <arg line='-var var.WebsiteFolderSource'/>
  </exec>

These snippets contain enough information to understand how it all works. Play with heat.exe switches to find out the combination you need. Good luck!

逆光飞翔i 2024-10-26 23:41:02

如果像我这样的人仍在寻求澄清:heat 片段中的 很重要,它是片段文件应安装位置的引用。如果您有多个片段并希望将其放置在不同的位置,则 DirectoryRef 是关键。

In case people like me still looking for clarification: The <DirectoryRef Id="WebsiteFolder"> in the heat fragment is important, it is the reference to where the fragment files should be installed. If you have multiple fragments and want to place it in different locations, the DirectoryRef is the key.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文