5

使用Costura.Fody工具将源DLL合并到目标EXE笔记 - AlexChow

 1 year ago
source link: https://www.cnblogs.com/densen2014/p/17182307.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

使用Costura.Fody工具将源DLL合并到目标EXE笔记

1.项目

https://github.com/Fody/Costura

2.安装

Install-Package Costura.Fody -Version 1.6.2

3.反射相关

Assembly.LoadFrom("someLibs.dll").GetType("xxx") 找不到文件

改为 Assembly.Load("someLibs").GetType("xxx")

4.升级包

上一版本升级文件包是零散的dll形式,这次使用了Costura.Fody合并,如果直接覆盖主程序执行文件,运行的时侯还是会优先使用目录里的dll文件,造成还是使用老版本dll, 我的做法是运行程序之前用升级文件包功能执行命令清除无用的dll文件,例如bat文件直接批处理

如果上一版是使用安装程序安装的带校验文件删除自动恢复的那就更糟糕了,必须得编辑配置文件FodyWeavers.xml指明不合并那几个dll文件

我使用的配置大概如下:

  1. 不包含debug符号
  2. dll解压到临时文件夹,有些功能需要dll物理文件
  3. 排除几个上面说的"带校验文件删除自动恢复的DLL"
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
  <Costura IncludeDebugSymbols='false' CreateTemporaryAssemblies='true'>
    <ExcludeAssemblies>
      Microsoft.ReportViewer.Common
      Microsoft.ReportViewer.DataVisualization
      Microsoft.ReportViewer.ProcessingObjectModel
      Microsoft.ReportViewer.WinForms
    </ExcludeAssemblies> 
  </Costura>

</Weavers>

参考文章

使用Costura.Fody工具将源DLL合并到目标EXE
https://www.cnblogs.com/cncc/p/7804511.html

FreeSql QQ群:4336577

BA & Blazor QQ群:795206915

Maui Blazor 中文社区 QQ群:645660665

知识共享许可协议

本作品采用 知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议 进行许可。欢迎转载、使用、重新发布,但务必保留文章署名AlexChow(包含链接: https://github.com/densen2014 ),不得用于商业目的,基于本文修改后的作品务必以相同的许可发布。如有任何疑问,请与我联系

本文来自博客园,作者:周创琳 AlexChow,转载请注明原文链接:https://www.cnblogs.com/densen2014/p/17182307.html

AlexChow

今日头条 | 博客园 | 知乎 | Gitee | GitHub

image

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK