【问题标题】:Compile project with multiple DLL file to single EXE without Visual Studio IDE在没有 Visual Studio IDE 的情况下将具有多个 DLL 文件的项目编译为单个 EXE
【发布时间】:2018-10-16 19:37:06
【问题描述】:

在编译我的项目时,我为每个命名空间创建一个 DLL 文件,并将它们包含到我将要构建的 EXE 中。我的问题是此操作会创建多个文件,并且输出似乎不可移植。

是否可以(以及如何)将所有 DLL 文件包含到单个 EXE 文件中?

这是我目前用来构建项目的构建脚本:

#!/bin/sh

if [ -d out ]; then
    rm -rf out/
fi;
mkdir out/

csc /nologo /target:library /out:out/StateMachine.Models.dll \
    StateMachine/Models/*.cs &&

csc /nologo /target:library /out:out/StateMachine.Builders.dll \
    /reference:out/StateMachine.Models.dll \
    StateMachine/Builders/*.cs &&

csc /nologo /target:exe /out:out/state-machine.exe \
    /reference:out/StateMachine.Models.dll \
    /reference:out/StateMachine.Builders.dll \
    StateMachine/Application.cs

我正在使用这个脚本,因为我的机器无法安装/运行 MSVS IDE。

【问题讨论】:

  • 使用 ILMerge.exe,如果它们都不是签名程序集。
  • 感谢您让我了解 ILMerge。由于我无法使用 ILMerge,因此我快速搜索了一下并找到了替代方法:ILRepack

标签: c# compilation


【解决方案1】:

使用 csc 编译您的 exe,然后使用 ILMerge 库:

ilmerge /target:winexe /out:SelfContainedProgram.exe Program.exe ClassLibrary1.dll classLibrary2.dll

Mono 有其他选择。

注意:库不应签名。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-09-20
    • 2012-10-23
    • 1970-01-01
    • 2011-05-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多