【问题标题】:My program folder only contains empty folders after installing with Wix#使用 Wix 安装后,我的程序文件夹仅包含空文件夹#
【发布时间】:2021-06-09 09:07:13
【问题描述】:

这就是我所拥有的

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 文件,它可以正常工作,但显然我的应用程序无法正常工作。

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

【问题讨论】:

    标签: c# installation deployment wix wixsharp


    【解决方案1】:

    使用 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 可添加变量,Transforms 采用 xls 过滤文件。

    【讨论】:

    • 感谢您的回复!一旦我编译我的wix#代码,这个wix代码不会被覆盖吗?如果是这样,我在 wix# 中找到了 Harvester 类。我可以用吗?
    • wix#中的收割机类我不熟悉。但是,一旦您编译删除旧文件,收割机就会自动生成 wxs 文件,因此您需要将它们排除在源代码之外。一般来说,尽管您应该始终使用热量来收集文件
    • 好的,所以我尝试将热量插入到我的 .wxs 中,但文件夹仍然是空的。但安装时间更长。这对我来说真的很奇怪,因为在程序概述中它说我的程序是 2.8mg 大但是文件在哪里??
    • 如果您正确运行 heat,您应该能够看到项目中的 .wxs 文件以及它生成的所有文件
    • 我使用 System.IO.Directory.GetFiles(clientFolderPath) .Where(f => f.EndsWith(".dll") || f.EndsWith(".exe") | 修复了它| f.EndsWith(".config")) .Select(f => new File(f)).ToArray() 而不是 Files 类
    【解决方案2】:

    而不是使用

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

    而不是解决问题

    【讨论】:

      猜你喜欢
      • 2016-08-13
      • 1970-01-01
      • 2012-06-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-17
      相关资源
      最近更新 更多