我正在尝试在安装期间将一些文件从安装位置复制到其他文件夹。当我将 SourceDirectory / SourceProperty 设置为硬编码位置时,设置正常工作。但当我将SourceDirectory替换为" INSTALLFOLDER "然后在安装过程中不会复制文件。
这是完整的源代码,
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="FolderCopySetupProject" Language="1033"
Version="1.0.0.0" Manufacturer="Microsoft"
UpgradeCode="PUT-GUID-HERE">
<Package InstallerVersion="200" Compressed="yes"
InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="Newer version installed." />
<MediaTemplate EmbedCab="yes" />
<Feature Id="ProductFeature" Title="FolderCopySetupProject" Level="1">
<ComponentGroupRef Id="ProductComponents" />
</Feature>
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="PE" />
</Directory>
</Directory>
</Fragment>
<Fragment>
<Property Id="DestFilesFolder" Value="C:\Temp\" />
<Component Id="cmpCC76E631D128DE73CBFBA4A3C6F364AC" Guid="*"
Directory="INSTALLFOLDER" KeyPath="yes">
<File Id="filCDC69907319511E61137A95EF50FAB30" Source="a.txt" />
<File Id="filCDC69907319511E61137A95EF50FAB31" Source="b.txt" />
</Component>
<Component Id="CMP_LOG4TXT" Guid="*"
Directory="INSTALLFOLDER" KeyPath="yes">
<CopyFile Id="Copy_LOG4TXT" SourceDirectory="INSTALLFOLDER"
SourceName="*"
DestinationProperty="DestFilesFolder"/>
</Component>
<ComponentGroup Id="ProductComponents">
<ComponentRef Id="cmpCC76E631D128DE73CBFBA4A3C6F364AC" />
<ComponentRef Id="CMP_LOG4TXT" />
</ComponentGroup>
</Fragment>
</Wix>
这是日志文件信息,
Executing op:
ComponentRegister(ComponentId={341BD660-7249-42DD-9744-DBEF0776AD52},KeyPath=C:\Program
Files (x86)\PE,State=3,,Disk=1,SharedDllRefCount=0,BinaryType=0) MSI
(s) (A0:64) [11:30:49:374]: Executing op:
ActionStart(Name=CreateFolders,Description=Creating
folders,Template=Folder: [1]) MSI (s) (A0:64) [11:30:49:375]:
Executing op: FolderCreate(Folder=C:\Program Files
(x86)\PE\,Foreign=0,,) MSI (s) (A0:64) [11:30:49:379]: Executing op:
FolderCreate(Folder=C:\Program Files (x86)\PE\,Foreign=0,,) MSI (s)
(A0:64) [11:30:49:380]: Executing op:
ActionStart(Name=InstallFiles,Description=Copying new
files,Template=File: [1], Directory: [9], Size: [6]) MSI (s)
(A0:64) [11:30:49:381]: Executing op:
ProgressTotal(Total=2,Type=0,ByteEquivalent=1) MSI (s) (A0:64)
[11:30:49:381]: Executing op: SetTargetFolder(Folder=C:\Program Files
(x86)\PE\) MSI (s) (A0:64) [11:30:49:381]: Executing op:
SetSourceFolder(Folder=1\PE\) MSI (s) (A0:64) [11:30:49:381]:
Executing op: ChangeMedia(,MediaPrompt=Please insert the disk:
,MediaCabinet=cab1.cab,BytesPerTick=65536,CopierType=2,ModuleFileName=C:\Windows\Installer\37a12097.msi,,,,,IsFirstPhysicalMedia=1)
MSI (s) (A0:64) [11:30:49:381]: Executing op:
FileCopy(SourceName=a.txt,SourceCabKey=filCDC69907319511E61137A95EF50FAB30,DestName=a.txt,Attributes=512,FileSize=1,PerTick=65536,,VerifyMedia=1,,,,,CheckCRC=0,,,InstallMode=58982400,HashOptions=0,HashPart1=-1183465204,HashPart2=-1464405568,HashPart3=-493239503,HashPart4=1629910889,,)
MSI (s) (A0:64) [11:30:49:382]: File: C:\Program Files
(x86)\PE\a.txt; To be installed; Won't patch; No existing file MSI
(s) (A0:64) [11:30:49:382]: Source for file
'filCDC69907319511E61137A95EF50FAB30' is compressed
看起来这些文件在&#34; INSTALLFOLDER&#34;对于复制,我不知道如何对组件进行排序以按顺序执行。 (InstallExecuteSequence On =&#34; AfterInstall&#34;类似的东西)
Anyhelp将非常感激
谢谢, 拉杰什
答案 0 :(得分:1)
也许你可以试试CopyFile element。更好的是:使用您的应用程序的启动序列在首次启动时进行任何文件复制,以避免将此操作与您的设置纠缠在一起。
Copy file from setup location to another location in wix on install
答案 1 :(得分:1)
我遇到了完全相同的情况,并且能够解决这个问题。
<CustomAction Id="BaselineSync_Cmd" Property="BaselineSync" Execute="immediate"
Value=""robocopy" "[BUP]" "[PROD]" /PURGE /e" />
<CustomAction Id="BaselineSync" BinaryKey="WixCA" DllEntry="CAQuietExec" Execute="deferred" Return="ignore" Impersonate="no"/>
<CustomAction Id="RoboCopy_Cmd" Property="RoboCopy" Execute="immediate"
Value=""robocopy" "[INSDIR]" "[PROD]" /e" />
<CustomAction Id="RoboCopy" BinaryKey="WixCA" DllEntry="CAQuietExec" Execute="deferred" Return="ignore" Impersonate="no"/>
<InstallExecuteSequence>
<Custom Action="BaselineSync_Cmd" After="StartServices"><![CDATA[NOT(Installed) AND (PROD <> "") AND (BUP <> "(none)")]]></Custom>
<Custom Action="BaselineSync" After="BaselineSync_Cmd"><![CDATA[NOT(Installed) AND (PROD <> "") AND (BUP <> "(none)")]]></Custom>
<Custom Action="RoboCopy_Cmd" After="BaselineSync"><![CDATA[NOT(Installed) AND (BUP <> "") AND (INSDIR <> "(none)")]]></Custom>
<Custom Action="RoboCopy" After="RoboCopy_Cmd"><![CDATA[NOT(Installed) AND (BUP <> "") AND (INSDIR <> "(none)")]]></Custom>
</InstallExecuteSequence>
这里发生的事情如下: 当我们调用安装程序时,我们传递三个变量,INSDIR,BUP和PROD。这些是路径。
安装程序的内容被推送到INSDIR的值。然后将BUP中的文件和文件夹复制到PROD中的文件和文件夹。我们有一个/PURGE
操作,这意味着首先删除了PROD。将BUP的文件复制到PROD后,我们通过PROD复制INSDIR的文件/文件夹并覆盖内容。这对我来说非常合适。
答案 2 :(得分:0)
截至目前,Wix无法在安装期间将文件夹复制到多个位置
虽然这是常见的情况,但是Wix无法处理这个
How to copy a folder (not a file) during installation with WiX?