Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
948 views
in Technique[技术] by (71.8m points)

windows installer - WIX: copy file to custom dir in another partition

I need to install my app's files to usual location like C:Program FilesMyApp
and also need to copy several of them into custom folder in another partition
(let's say D:CustomFolder, it's allowed to hardcode it).

Install should be silent - no gui or wizard. And alose everything should be in one *.msi file.

I can do that via CustomActions, but elegant-declarative way is preferable.

Has anyone tried this before?
Thanks.

UPDATE: Forgot to mention, that it's allowed for files that should be on separate partition to be in C:Program FilesMyApp

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Solved. The approach is:

  1. Specify custom folder where file should be put:

    <Property Id="MY_CUSTOM_DESTINATION" Value="D:MyCustomFolder" />

  2. Put <Copy ..> directive into <File ...> which should be copied

<DirectoryRef Id="MyAppFolderThatIsInProgramFiles">
     <Component Id="MyComponent" Guid="some_guid">
      <File Id="MyFileXml" Source="MyFile.xml" KeyPath="yes" >
          <CopyFile Id="Copy_MyFileXml" DestinationProperty="MY_CUSTOM_DESTINATION"/>
      </File>
     </Component>
</DirectoryRef>

p.s. as a side-effect, file specified in <File Id="MyFileXml" ... /> will be put into both location: C:Program FilesMyApp and D:MyCustomFolder, but that's correct for my task.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...