Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copy external file to install directory WiX

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?

like image 916
Sonhja Avatar asked Jan 25 '26 00:01

Sonhja


1 Answers

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>
like image 53
Christopher Painter Avatar answered Jan 26 '26 23:01

Christopher Painter



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!