• LMerge-github


    ILMerge

    ILMerge是一个将多个.NET程序集合并到一个程序集中的实用程序。它可以免费使用,并以NuGet包的形式提供

    如果您在使用它时遇到任何问题,请与我们联系。(mbarnett at microsoft dot com)。但首先尝试阅读文档

    ILMerge接受一组输入程序集并将它们合并到一个目标程序集中。输入程序集列表中的第一个程序集是主程序集。当主程序集是可执行文件时,目标程序集将创建为具有与主程序集相同的入口点的可执行文件。此外,如果主程序集具有强名称,并且提供了.snk文件,则使用指定的键重新签名目标程序集,以使其具有强名称。

    ILMerge打包为控制台应用程序。但它的所有功能也可以通过编程方式获得。

    有几个选项可以控制ILMerge的行为。有关详细信息,请参阅该工具随附的文档。

    目前的版本是2.14.1208(2014年12月8日创建)。注意:不再有在v1.1运行时中运行的ILMerge版本。

    ILMerge在v4.0 .NET运行时中运行,但它也能够使用它来合并来自其他框架版本的程序集/targetplatformoption。请参阅文档。(但是,它只能为v2(及更高版本)程序集合并PDB文件。)

    目前,ILMerge仅适用于基于Windows的平台。它还不支持Rotor或Mono。

    如果使用ASP.NET v2.0,则它提供了一个工具(基于ILMerge)来组合在预编译期间创建的程序集。您可以从ASP.NET网站获取更多详细信息。

    安装

    ilmerge NuGet页面所述,该软件包可以从Visual Studio环境安装。在Solution Explorer视图中展开项目容器。右键单击references并选择Manage NuGet Packages

    NuGet参考设置

    确保Package source设置为nuget.org

    NuGet包源

    接下来,单击Tools - NuGet Package Manager - Package Manager Console。确保Package source也设置为nuget.org

    NuGet Pakage Manager Console source.PNG

    要为项目安装,请使用Install-Package命令:

    Install-Package ilmerge -Version 3.0.21
    

    用法

    的MSBuild

    ILMerge可以使用NuGet包在MSBuild中使用:

    < Project  Sdk = “ Microsoft.NET.Sdk ” >
    
      < ItemGroup >
        < PackageReference  Include = “ ILMerge ”  Version = “ 2.15.0 ” />
      </ ItemGroup >
    
      < Target  Name = “ ILMerge ” >
         <! - ILMergePath属性指向ILMerge.exe控制台应用程序的位置- > 
        < Exec  Command = “ $(ILMergeConsolePath)/out:Merged.dll File1.dll File2.dll ” />
      </ Target >
    
    </ Project >

    编辑项目.csproj.vbproj文件(在相应<Project> .. </Project>标记内,通常在文件末尾。如果编译特定目标,请使用显式目录,例如Binx64Release

    <ItemGroup>
        <PackageReference Include="ILMerge" Version="2.15.0" />
      </ItemGroup>
    
      <Target Name="ILMerge">
        <!-- the ILMergePath property points to the location of ILMerge.exe console application -->
        <Exec Command="$(ILMergeConsolePath) Binx64Releasemyapp.exe  /out:myapp.exe Binx64ReleaseFile1.dll Binx64ReleaseFile2.dll Binx64ReleaseFile3.dll " />
      </Target>
    

    虽然XML文件中通常会忽略空格,但在这种情况下,确切的文本将作为DOS命令处理,因此为了提高可读性,请使用克拉^(shift 6)行扩展器:

    <ItemGroup>
        <PackageReference Include="ILMerge" Version="2.15.0" />
      </ItemGroup>
    
      <Target Name="ILMerge">
        <!-- the ILMergePath property points to the location of ILMerge.exe console application -->
        <Exec Command="$(ILMergeConsolePath) Binx64Releasemyapp.exe ^
        /out:myapp.exe ^
        Binx64ReleaseFile1.dll ^
        Binx64ReleaseFile2.dll ^ 
        Binx64ReleaseFile3.dll " />
      </Target>
    

    DOS dir / b选项可以帮助列出所有依赖项:

    dir binx64Debug*.dll /b
    

    从Visual Studio Developer命令提示符:

    #下载/安装软件包参考
    msbuild / t:恢复
    
    #运行ILMerge目标
    msbuild / t:ILMerge

    ILMerge在批处理文件中运行:

    此处不需要Visual Studio Developer命令提示符,因为msbuild未使用。

    @echo off
    
    :: this script needs https://www.nuget.org/packages/ilmerge
    
    :: set your target executable name (typically [projectname].exe)
    SET APP_NAME=myapp.exe
    
    :: Set build, used for directory. Typically Release or Debug
    SET ILMERGE_BUILD=Debug
    
    :: Set platform, typically x64
    SET ILMERGE_PLATFORM=x64
    
    :: set your NuGet ILMerge Version, this is the number from the package manager install, for example:
    :: PM> Install-Package ilmerge -Version 3.0.21
    :: to confirm it is installed for a given project, see the packages.config file
    SET ILMERGE_VERSION=3.0.21
    
    :: the full ILMerge should be found here:
    SET ILMERGE_PATH=%USERPROFILE%.nugetpackagesilmerge\%ILMERGE_VERSION%	ools
    et452
    :: dir "%ILMERGE_PATH%"ILMerge.exe
    
    echo Merging %APP_NAME% ...
    
    :: add project DLL's starting with replacing the FirstLib with this project's DLL
    "%ILMERGE_PATH%"ILMerge.exe Binx64Release\%APP_NAME%  ^
      /lib:Bin\%ILMERGE_PLATFORM%\%ILMERGE_BUILD% ^
      /out:%APP_NAME% ^
      FirstLib.dll ^
      mylib1.dll ^
      Microsoft.lib2.dll ^
      SomeOtherLib.dll ^
      otherlibdirotherlib.dll 
    
    
    :Done
    dir %APP_NAME%
  • 相关阅读:
    Mysql常用sql语句(6)- limit 限制查询结果的条数
    Mysql常用sql语句(5)- as 设置别名
    Mysql常用sql语句(4)- distinct 去重数据
    Mysql常用sql语句(3)- select 查询语句基础使用
    Jenkins(8)- CentOS 7.x 通过yum安装jenkins
    Jmeter系列(11)- 并发线程组Concurrency Thread Group详解
    Jmeter系列(10)- 阶梯加压线程组Stepping Thread Group详解
    Jmeter系列(9)- jmeter插件入门篇
    Jmeter系列(8)- test plam测试计划参数详解
    Jmeter系列(6)- test plan测试计划详细讲解
  • 原文地址:https://www.cnblogs.com/1175429393wljblog/p/10767832.html
Copyright © 2020-2023  润新知