My program folder only contains empty folders after installing with Wix#

196 views Asked by At

Heres what i have

var project =
            new ManagedProject(productName,
                new Dir($"%ProgramFiles%\\{companyName}",
                    new Dir($"{productName}",
                        new Files(clientFolderPath,
                                f => f.EndsWith(".dll") ||
                                        f.EndsWith(".exe") ||
                                        f.EndsWith(".config"))))

If I use File instead of Files and only include one .exe file it works fine but then obviously my app doesnt work.

How can I make sure all the files in the referenced output path are included. Im sure the path is correct since the installation creates the folders present in the the output folder, but none of the files.

2

There are 2 answers

5
misha130 On

Use heat.exe instead to harvest all the files.

You can add this to your csproj so it automatically picks up the files and creates a wxs

<HeatDirectory OutputFile="ComponentsGenerated.wxs" DirectoryRefId="clientFolderPath" 
 ComponentGroupName="PublishedComponents" SuppressCom="true" 
 Directory="..\..\directory\to\your\folder\to\harvest"
 SuppressFragments="true" SuppressRegistry="true" 
 SuppressRootDirectory="true" AutoGenerateGuids="false" GenerateGuidsNow="true" ToolPath="$(WixToolPath)" 
/>

Please note to setup a DirectoryRefId prior to doing this so a directory reference exists

There are many things you can add to this such as PreprocessorVariable which adds variables and a Transforms that takes an xls that filters the files.

0
Felix t On

instead of using

new Files(clientFolderPath,
          f => f.EndsWith(".dll") ||
               f.EndsWith(".exe") ||
               f.EndsWith(".config"))))

i used

    System.IO.Directory.GetFiles(clientFolderPath) 
          .Where(f => f.EndsWith(".dll") || f.EndsWith(".exe") || f.EndsWith(".config")) 
          .Select(f => new File(f))
          .ToArray()

instead to fix the issue