2

I want to move a file from one Directory to another and it simply does nothing.

Here is the part from my Product.wxs:

<Feature Id="ProductFeature" Title="$(var.ProductName)" Level="1">
  <ComponentRef Id="testCopy"/>
</Feature>

<DirectoryRef Id="dirConfigs">
  <Component Id="web.config" Guid="8736259D-4FEE-4826-B109-76DD3B0EDAE7">
    <CopyFile Id="CopyWebConfig" 
              SourceProperty="dirProject"
              SourceName="Web.config"
              DestinationProperty="dirConfigs"
              DestinationName="Web.config"
              />
  </Component>
</DirectoryRef>

<Directory Id="TARGETDIR" Name="SourceDir">
  <Directory Id="$(var.PlatformProgramFilesFolder)">
    <Directory Id="dirParent" Name="$(var.CustomerName)">
      <Directory Id="dirProject" Name="$(var.ProductName)">
        <Directory Id="dirConfigs" Name="$(var.ConfigFolderName)">
        </Directory>
      </Directory>
    </Directory>
  </Directory>
</Directory>

Edit I also tried with Source/DestinationDirectory instead of Source/DestinationProperty Any ideas? Thanks in advance!

David Walser
  • 183
  • 20
  • 1
    It is generally easier to do file-copying on application launch instead of as part of the setup - not always possible for web apps. Application launch code is easier to implement, debug and change as you need to. Is that an option? [I have this old answer on CopyFile](https://stackoverflow.com/a/1564006/129130). It looks like you are copying the file to the folder it is already in. Try changing `DestinationProperty="dirConfigs"` to `DestinationProperty ='DesktopFolder'`as a test? – Stein Åsmul Jul 28 '20 at 15:36
  • Another approach that Christopher Painter has suggested: ["an override file" for web.config](https://stackoverflow.com/a/49142733/129130). – Stein Åsmul Jul 28 '20 at 15:40
  • @SteinÅsmul thanks for your comment! Copying to DesktopFolder wont work either, the CopyFile tag needs to be part of the File tag, unfortunately "an override file" for web.config is not applicable for us :/ – David Walser Aug 03 '20 at 09:39
  • I am not sure what happened during your testing, but you can try to find better samples on github.com. [Here is a "stored search"](https://github.com/search?q=%3CCopyFile+%3CWix+extension%3Awxs&type=Code). At the moment of writing, about 500+ hits. – Stein Åsmul Aug 03 '20 at 10:50

1 Answers1

-2

I would rely on a deferred CustomAction invoking the command line "copy" command rather than using CopyFile and execute it, like in this SO question.

You'll need admin permissions if you are going to write the file in a protected folder or a folder requiring administrative access (on Windows Vista+, anything outside the %USER% folder.

madduci
  • 2,635
  • 1
  • 32
  • 51