Wix 工具集:在根磁盘(系统磁盘或 c:\)中创建目录并复制其中的文件 [英] Wix toolset: create directory in root disk (system disk or c:\) and copy files inside

查看:34
本文介绍了Wix 工具集:在根磁盘(系统磁盘或 c:\)中创建目录并复制其中的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道 stackoverflow 中有类似的问题:

I'm aware of similar questions inside stackoverflow:

WIX:WixUI_InstallDir 中的默认目录,

WIX 安装程序根目录和版本控制

是否可以有两个根目录WIX,

复制文件到另一个分区的自定义目录

如何在wix中创建目录?

然而,它们都没有显示在 C:\ 文件夹中创建文件夹的简单和直接的代码(不是硬编码,但应该是根磁盘或系统磁盘或任何你称之为包含 Windows 文件夹的磁盘)和复制里面的文件.

however none of them shows a simple and immediate code to create a folder inside the C:\ folder (not hard coded but should be the root disk or system disk or whatever you would call the disk which contains the Windows folder) and to copy files inside it.

换句话说,Wix 如何创建 C:\MynewDir\example.jar 文件夹?

In other words how can Wix create a C:\MynewDir\example.jar folder?

这是我尝试过的:

<?xml version="1.0" encoding="UTF-8"?>
<!-- WiX installer MyProgram by Mark Seuffert -->
<?define ProductVersion = "13.1.2.3"?>
<?define ProductUpgradeCode = "12345678-1234-1234-1234-111111111112"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Product Id="*" UpgradeCode="$(var.ProductUpgradeCode)" Name="MyProgram" Version="$(var.ProductVersion)" Manufacturer="COMPANY" Language="1033">
        <Package InstallerVersion="200" Compressed="yes" Comments="Windows Installer Package" />
        <Media Id="1" Cabinet="product.cab" EmbedCab="yes" />

        <Directory Id="TARGETDIR" Name="SourceDir">
            <Directory Id="ProgramFilesFolder">
                <Directory Id="INSTALLDIR" Name="MyProgram">
                    <Component Id="ApplicationFiles" Guid="12345678-1234-1234-1234-222222222222">
                        <File Id="ApplicationFile1" Source="C:\Users\user\Desktop\myprogram.exe" />
                    </Component>
                </Directory>
            </Directory>

            <Directory Id="ANOTHERLOCATION" FileSource="C:\MynewDir">
            </Directory> 
        </Directory>

        <DirectoryRef Id="ANOTHERLOCATION" FileSource="C:\MynewDir">
          <Component Id="ApplicationFiles2" Guid="12345678-1234-1234-1235-111111111111">
                    <File Id="ApplicationFile2" Source="C:\Users\user\Desktop\InstallerFiles_13_4_9_3\myprogramLauncher.jar" />
                    <CreateFolder />
            </Component>
        </DirectoryRef>

        <InstallExecuteSequence>
            <RemoveExistingProducts After="InstallValidate" />
        </InstallExecuteSequence>
        <Feature Id="DefaultFeature" Level="1">
            <ComponentRef Id="ApplicationFiles2" />
            <ComponentRef Id="ApplicationFiles" />
        </Feature>
    </Product>
</Wix>

编辑 1:Yan Sklyarenko 刚刚找到了我要找的东西,那就是 WindowsVolume(我不知道我是怎么在 http://msdn.microsoft.com/en-us/library/windows/desktop/aa370905%28v=vs.85%29.aspx#system_folder_properties 微软文档).

EDIT 1: Yan Sklyarenko just found what I was looking for, that's the WindowsVolume (I don't know how I missed it inside http://msdn.microsoft.com/en-us/library/windows/desktop/aa370905%28v=vs.85%29.aspx#system_folder_properties microsoft document).

但是我如何用 FileSource="[WindowsVolume]MynewDir" 替换 FileSource="C:\MynewDir" ???因为显然即使使用 WINDOWSVOLUME 选择的结果卷始终是 D:\ 在我的计算机中有更多可用空间:(

However how do I replace FileSource="C:\MynewDir" with FileSource="[WindowsVolume]MynewDir" ??? because apparently even with WINDOWSVOLUME the resulting volume chosen is always D:\ in my computer which has more available space :(

EDIT 2 我使用 Yan Sklyarenko 的第二个示例更新了我的代码(@@@@newpart@@@@ 标识了代码不同的部分),但是行为仍然相同,安装程序选择了磁盘有更多的可用空间(在我的情况下为 D:\)而不是 C:\,Windows 所在的位置..

EDIT 2 I updated my code using Yan Sklyarenko's second sample ( @@@@newpart@@@@ identifies parts where code differs), however behaviour is still the same, the installer chooses the disk with more free space (D:\ in my case) and not C:\ where windows is..

<?xml version="1.0" encoding="UTF-8"?>
<!-- WiX installer MyProgram by Mark Seuffert -->
<?define ProductVersion = "13.1.2.3"?>
<?define ProductUpgradeCode = "12345678-1234-1234-1234-111111111112"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Product Id="*" UpgradeCode="$(var.ProductUpgradeCode)" Name="MyProgram" Version="$(var.ProductVersion)" Manufacturer="COMPANY" Language="1033">
        <Package InstallerVersion="200" Compressed="yes" Comments="Windows Installer Package" />
        <Media Id="1" Cabinet="product.cab" EmbedCab="yes" />

        <Directory Id="TARGETDIR" Name="SourceDir">
            <Directory Id="ProgramFilesFolder">
                <Directory Id="INSTALLDIR" Name="MyProgram">
                    <Component Id="ApplicationFiles" Guid="12345678-1234-1234-1234-222222222222">
                        <File Id="ApplicationFile1" Source="C:\Users\user\Desktop\myprogram.exe" />
                    </Component>
                </Directory>
            </Directory>

            <Directory Id="ANOTHERLOCATION" FileSource="C:\MynewDir">
             @@@@newpart@@@@<Component Id="ApplicationFiles2" Guid="12345678-1234-1234-1235-111111111111">
                    <File Id="ApplicationFile2" Source="C:\Users\user\Desktop\InstallerFiles_13_4_9_3\myprogramLauncher.jar" />
                    <CreateFolder />
               </Component>
            </Directory> 
        </Directory>

        @@@@newpart@@@@<SetDirectory Id="ANOTHERLOCATION" Value="[WINDOWSVOLUME]" />

        <InstallExecuteSequence>
            <RemoveExistingProducts After="InstallValidate" />
        </InstallExecuteSequence>
        <Feature Id="DefaultFeature" Level="1">
            <ComponentRef Id="ApplicationFiles2" />
            <ComponentRef Id="ApplicationFiles" />
        </Feature>
    </Product>
</Wix>

EDIT 3 上面的最后一个代码片段应该可以工作,但是按照建议将 WINDOWSVOLUME 的大小写更改为 WindowsVolume.

EDIT 3 The last code snippet above should work however change the casing of WINDOWSVOLUME to WindowsVolume as suggested.

推荐答案

以下是基于您的简化代码的完整工作解决方案(注意代码中的注释):

Here is a complete working solution based on your code simplified (notice the comment in the code):

<?define ProductVersion = "13.1.2.3"?>
<?define ProductUpgradeCode = "12345678-1234-1234-1234-111111111112"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" UpgradeCode="$(var.ProductUpgradeCode)" Name="MyProgram"
         Version="$(var.ProductVersion)" Manufacturer="COMPANY" Language="1033">
    <Package InstallerVersion="200" Compressed="yes" />
    <Media Id="1" Cabinet="product.cab" EmbedCab="yes" />

    <Directory Id="TARGETDIR" Name="SourceDir">
        <Directory Id="ProgramFilesFolder">
            <Directory Id="INSTALLDIR" Name="MyProgram" />
            <Directory Id="ANOTHERLOCATION" />
        </Directory>
    </Directory>

    <!-- The casing of 'ANOTHERLOCATION' and 'WindowsVolume' is very important here.
         Replace 'MyNewDir' with the correct name of the folder you want on
         WindowsVolume.
    -->
    <SetDirectory Id="ANOTHERLOCATION" Value="[WindowsVolume]MyNewDir" />


    <Feature Id="DefaultFeature" Level="1">
      <Component Directory="INSTALLDIR">
        <File Id="ApplicationFile1" Source="C:\Users\user\Desktop\myprogram.exe" />
      </Component>
      <Component Directory="ANOTHERLOCATION">
        <File Id="ApplicationFile2" Source="C:\Users\user\Desktop\InstallerFiles_13_4_9_3\myprogramLauncher.jar" />
      </Component>
    </Feature>
</Product>
</Wix>

这篇关于Wix 工具集:在根磁盘(系统磁盘或 c:\)中创建目录并复制其中的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆