.NET打包合並dll方法


 

在NuGet搜索Costura,引用此dll,打包成EXE文件的時候會合並到EXE,不會產生dll,比如數據庫dll(OracleAccessDatabase.dll)

注意:由於可能會報如下錯誤~

Fody is only supported on MSBuild 16 and above. Current version: 15.

則需要回滾下版本號,可以在VS的程序包管理器控制台中輸入Install-Package Fody -Version 4.2.1來安裝4.2.1版本的Fody,然后輸入Install-Package Costura.Fody -Version 3.3.3來安裝3.3.3版本的Costura.Fody。

 

 再次進行重新生成項目,如果報如下錯誤~

Fody: No configuration entry found for the installed weaver Costura. This weaver will be skipped. You may want to add this weaver to your FodyWeavers.xml

則需要修改或者添加, FodyWeavers.xml

 

 添加內容如下:

<?xml version="1.0" encoding="utf-8"?>
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
  <Costura />
</Weavers>

最后再次重新生成,則所有dll合並到同一個exe文件


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM