首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >Wix工具集:在根磁盘(系统盘或c:\)中创建目录,并在其中复制文件

Wix工具集:在根磁盘(系统盘或c:\)中创建目录,并在其中复制文件
EN

Stack Overflow用户
提问于 2013-04-10 16:45:52
回答 2查看 21.7K关注 0票数 18

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

WIX:default directory in WixUI_InstallDir

WIX installer root directory and versioning

Is it possible to have two root directories in WIX

copy file to custom dir in another partition

How to create a directory in wix?

然而,它们都没有显示出在C:\文件夹中创建文件夹(不是硬编码的,但应该是根磁盘、系统磁盘或任何您所称的包含Windows文件夹的磁盘)中的简单而直接的代码,并复制其中的文件。

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

这是我尝试过的:

代码语言:javascript
复制
<?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文档中遗漏了它)。

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

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

代码语言:javascript
复制
<?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>

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

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15921078

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档