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

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

问题描述

我正在为具有许多依赖项的.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捆绑包创建的答案,似乎可以保留我的产品原样存在一个文件中,而另一个文件中有一个捆绑包引用该产品,但是我似乎找不到任何示例。

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>


推荐答案

单文件部署? :我不确定这是否是您的要求,但似乎您想将所有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 作为嵌入式资源:项目菜单 >> 属性 >> 资源 >> 添加现有文件

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

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

共享项目 :难以捉摸的 共享项目 用于.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.

链接

Links:

  • How to merge multiple assemblies into one?
  • Embedding DLLs in a compiled executable

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

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