如何在 WiX 中将依赖项 .dll 文件与主要产品捆绑在一起 [英] How to bundle dependency .dll files with main product in WiX

查看:23
本文介绍了如何在 WiX 中将依赖项 .dll 文件与主要产品捆绑在一起的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为具有许多依赖项的 .NET 项目创建 wix 安装程序.目前,我有一个可用的 .msi 安装程序,但正如预期的那样,所有依赖项 .dll(以及资源​​文件夹)都与已安装的应用程序放在同一目录中,而不是与其捆绑在一起.

I am creating a wix installer for a .NET project with many dependencies. Currently, I have a working .msi installer, but as expected all the dependency .dll's (as well as a resources folder) are placed in the same directory as the installed application rather than being bundled with it.

阅读 WIX Bundle Creation 的答案后,似乎可以将我的产品保持原样文件并有另一个文件,其中包含引用此产品的捆绑包,但我似乎找不到任何示例.

Reading the answer to WIX Bundle Creation, it seems possible to keep my Product as is in one file and have another file with a Bundle referencing this product, but I cannot seem to find any examples of this.

有没有简单的方法可以做到这一点?我已经在下面列出了产​​品代码的大纲.

Is there a simple way to do this? I've included the outline of the product code below.

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
     xmlns:ui="http://schemas.microsoft.com/wix/UIExtension">  
    <Product Id="*" Name="#####" Language="1033" Version="1.0.0.0" Manufacturer="..." UpgradeCode="...">
        <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" Platform="x64"/>

    <Property Id="WIXUI_INSTALLDIR" Value="INSTALLFOLDER" />
    <UIRef Id="WixUI_InstallDir" />

        <MajorUpgrade AllowSameVersionUpgrades="yes" DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
        <MediaTemplate EmbedCab="yes"/>

        <Feature Id="ProductFeature" Title="alphaInstaller" Level="1">
            <ComponentGroupRef Id="ProductComponents" />
            <ComponentGroupRef Id="ProductMenuComponents" />
            <ComponentGroupRef Id="DependencyComponents"/>
            <ComponentGroupRef Id="ResourcesComponents"/>
        </Feature>
    </Product>

    <Fragment>
        <Directory Id="TARGETDIR" Name="SourceDir">
         <Directory Id="ProgramMenu64Folder">
            ...
        </Directory>
    </Fragment>

    <Fragment>
        <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
          <Component Id="CMP_alphaGUISetup" Win64="yes">
             <File Id="FILE_alphaGUIApplication.exe" Source="$(var.alphaGUI.TargetPath)" KeyPath="yes"></File>
          </Component>
        </ComponentGroup>
    <ComponentGroup Id="ProductMenuComponents" Directory="ApplicationProgramsFolder">
      <Component Id="ApplicationShortcut" Guid="..." >
        <Shortcut .../>
        <RemoveFolder Id="ApplicationProgramsFolder" On="uninstall"/>
        <RegistryValue .../>
      </Component>
    </ComponentGroup>
    <ComponentGroup Id="DependencyComponents" Directory="INSTALLFOLDER" Source=...>
      <Component Id="log4net">
        <File Name="log4net.dll" />
      </Component>
        ...
    </ComponentGroup>
    <ComponentGroup Id="ResourcesComponents" Directory="ResourcesFolder" Source=...>
      <Component Id="logo.ico">
        ...
    </ComponentGroup>
    </Fragment>
</Wix>

推荐答案

Single-file-deployment?:我有点不确定这是否是您要问的,但您似乎想将所有 dll 嵌入到单个 .NET 可执行文件中?

Single-file-deployment?: I am a little unsure if this is what you ask, but it seems you want to embed all dlls within a single .NET executable file?

Ilmerge.exe:这不是我的专业领域,但有这个答案:在已编译的可执行文件中嵌入 DLL,您可以查看.工具 Ilmerge.exe - 操作方法(另见下面的答案).模拟:

Ilmerge.exe: This is not my area of expertise, but there is this answer: Embedding DLLs in a compiled executable that you can check out. The tool Ilmerge.exe - how-to (also see answer below). Mock-up:

ILMerge.exe /target:winexe /out:All.exe Main.exe one.dll two.dll

我从来没有用过这个.如果它适用于所有情况,我会感到非常惊讶.明显地.值得一试?使用 virustotal.com(发布模式二进制文件)测试合并的二进制文件,以确定您是否触发了任何恶意软件警告.

I have never used this. I would be very surprised if it worked for all cases. Obviously. Worth a try? Test merged binary using virustotal.com (release mode binary) to determine if you trigger any malware warnings.

资源文件嵌入:如果需要,您还可以在 .NET 可执行文件中嵌入资源文件,例如图像、html 模板和其他内容.我能找到的最简洁的模型(来源):

  • 添加文件 TestFile.txt 作为嵌入资源:Project Menu >> 属性 >> Resources >> 添加现有文件.

  • Add file TestFile.txt as embedded resource: Project Menu >> Properties >> Resources >> Add Existing file.

代码访问:string queryFromResourceFile = Properties.Resources.Testfile.ToString();

共享项目:有一个难以捉摸的Shared Project" 用于 .NET 项目/C# 类型,它被编译到您的主要在构建时可执行.不确定这个项目类型是什么时候出现的.它存在于 VS2017 中.

Shared Project: There is the elusive "Shared Project" for .NET projects / C# type that gets compiled into your main executable at build time. Not sure when this project type came along. It is present in VS2017.

单一项目选项:显然,您也可以将所有代码文件移动到同一个项目中并以这种方式编译可执行文件.除非您打算将所有源文件永久保存在一个项目中,否则我不会这样做.否则你会得到一个非常愚蠢的构建过程?我想应该提到所有选项,以便我们记住或承认它们为什么不好.

Single Project Option: You could also obviously move all code files into the same project and compile an executable that way. I wouldn't do this unless you intend to keep all source files in one project permanently. Otherwise you get a very silly build process? I guess all options should be mentioned, so we remember or acknowledge why they are bad.

更多选择?:我相信还有更多选择.可能是我不知道的编译器的一些标志.有知道的请补充.在 youtube 上发现了这种有点疯狂的方法(将 dll 资源设置为嵌入 Visual Studio项目,然后添加代码以读取嵌入的程序集).我想知道杀毒软件是如何判断后者的?使用 virustotal.com(发布模式二进制文件)进行测试.我猜与 Ilmerge.exe 合并的二进制文件也是如此.

Further Options?: I am sure there are further options. Probably some flags for the compiler that I am unaware of. Please add if you know of any. Found this somewhat crazy approach on youtube (setting dll resources to be embedded inside the Visual Studio project, and then add code to read the embedded assembly). I wonder how anti-virus software judges the latter? Test using virustotal.com (release mode binary). Same goes for binaries merged with Ilmerge.exe I guess.

链接:

这篇关于如何在 WiX 中将依赖项 .dll 文件与主要产品捆绑在一起的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆