3

I have the same problem like here. I have a .config file that I want to copy from the source directory (where my .msi file is, to my install directory.

I tried several things:

1st thing I tried:

<DirectoryRef Id="ProgramFilesFolder">
  <Component Id="$(var.productFamily)$(var.productSummary).config" Guid="$(var.GUID_CMP_DemoConfig)" KeyPath="yes">
    <CopyFile Id="$(var.productFamily)$(var.productSummary).config"
          SourceName="$(var.productFamily)$(var.productSummary).exe.config"
          SourceProperty="SOURCEDIR"
          DestinationDirectory="$(var.productFamily)$(var.productType)"
          DestinationName="$(var.productFamily)$(var.productSummary).exe.config"
           >
    </CopyFile>
  </Component>
</DirectoryRef>

But this method failed, as it's trying to copy the file before the application is installed, so my directory still doesn't exist.

2nd thing I tried:

Add it as another component of the installer.

      <Component Id="$(var.productFamily)$(var.productSummary).config" Guid="$(var.GUID_CMP_DemoConfig)">
        <File Id="$(var.productFamily)$(var.productSummary).config"
              Name="$(var.productFamily)$(var.productSummary).exe.config"
              DiskId="1" KeyPath="yes"
              Source="$(var.productFamily)$(var.productSummary).exe.config" >
        </File>
      </Component>

With this one I should be able to copy from my Release folder of the installer to my INSTALLDIR, but when I build the project on VS 2010, it doesn't find the file...

3rd thing I tried:

I tried to change the SOURCEDIR var to my own variable, so I could use it as a regular component, doing this. But it doesn't let me change the variable name. It says when trying to change it:

heat.exe : error HEAT0319 : The '-out' or '-o' parameter must specify a file path.

So I only want to copy a file from where my .msi is located, but I still couldn't do it...

Any ideas?

Community
  • 1
  • 1
Sonhja
  • 8,230
  • 20
  • 73
  • 131
  • possible duplicate of [WiX: CopyFile attributes](http://stackoverflow.com/questions/465788/wix-copyfile-attributes) – Rob Mensching Apr 04 '13 at 13:06
  • I recommend duplicate because it sounds like you are doing the same thing as is answered in the other question. If you are doing something different, can you please update the first paragraph of your question to explain how your question is different from the duplicate? – Rob Mensching Apr 04 '13 at 13:19
  • @RobMensching I'm doing the same, but as I said, their solution doesn't work for me. The problem is not different, but I don't understand the answers... – Sonhja Apr 04 '13 at 13:40
  • @Rob- I was under the impression that DuplicateFiles could only copy a file that was installed by the installer. His description is he wants to copy a file from SourceDir. I think he's trying to create an installer with a variation point without rebuilding it. – Christopher Painter Apr 04 '13 at 14:21
  • I'm trying to create an installer that takes an external file and copies it to the project, as the components do, but this file is located where the `.msi` is. Rebuilding it's not a problem. The problem is that any solution I tried doesn't work :( – Sonhja Apr 04 '13 at 14:33
  • @ChristopherPainter you are correct but the `MoveFile` table can copy any file anywhere. We wrap up both of those tables with the `CopyFile` element in WiX toolset. – Rob Mensching Apr 04 '13 at 17:56
  • I'll have to dig into that deeper. So much to remember. :) – Christopher Painter Apr 04 '13 at 18:08

1 Answers1

3

You can use the Compressed attribute on the File element to exclude a file from being compressed into the MSI at build time. Then you can replace the contents of this file on a case by case basis. Author like normal and install like normal and everything will be fine without having to do anything fancy.

For example the following adds the Compressed attribute to override the default compression set by the Package element:

<Component>
  <File Source="$(var.productFamily)$(var.productSummary).exe.config"
        Compressed='no' />
  </File>
</Component>
Rob Mensching
  • 33,834
  • 5
  • 90
  • 130
Christopher Painter
  • 54,556
  • 6
  • 63
  • 100