使用 Wix# 安装后,我的程序文件夹仅包含空文件夹

问题描述

这是我所拥有的

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"))))

如果我使用 File 而不是 Files 并且只包含一个 .exe 文件,它可以正常工作,但显然我的应用程序不起作用。

如何确保引用的输出路径中的所有文件都包含在内。 我确定路径是正确的,因为安装会创建输出文件夹中存在的文件夹,但没有创建任何文件

解决方法

改用 heat.exe 来收集所有文件。

您可以将其添加到您的 csproj 中,以便它自动获取文件并创建一个 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)" 
/>

请注意在执行此操作之前设置 DirectoryRefId,以便存在目录引用

您可以向其中添加许多内容,例如添加变量的 PreprocessorVariable 和采用过滤文件的 xls 的 Transforms。

,

而不是使用

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

我用过

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

改为解决问题