在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文件