0

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.

Felix t
  • 19
  • 6

2 Answers2

0

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.

misha130
  • 5,457
  • 2
  • 29
  • 51
  • thanks for the response! wont this wix code be overwritten as soon as i compile my wix# code? if so i found the Harvester class in wix#. can i use that? – Felix t Jun 09 '21 at 10:28
  • I am not familiar with it the harvester class in wix#. But the harvester auto generates wxs files as soon as you compile deleting the old ones so you need to keep them out of your source code. In general though you should always use heat to gather the files – misha130 Jun 09 '21 at 10:37
  • okay so i tried just inserting the heat into my .wxs but the folders are still empty. but the installation took longer. this is really weird to me since in the programs overview it says that my program is 2.8mg large but where are the files?? – Felix t Jun 09 '21 at 11:25
  • If you ran heat properly you should be able to see the .wxs files in your project with all the files that it generated – misha130 Jun 09 '21 at 12:54
  • i fixed it by using System.IO.Directory.GetFiles(clientFolderPath) .Where(f => f.EndsWith(".dll") || f.EndsWith(".exe") || f.EndsWith(".config")) .Select(f => new File(f)).ToArray() instead of the Files class – Felix t Jun 10 '21 at 09:42
0

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

Felix t
  • 19
  • 6