.net core 發布單個exe 文件, 並優化縮小大小


最新版的.net core 3.0 可以通過命令行發布為exe文件,

操作步驟如下:

在項目目錄下打開控制台:

輸入命令:

dotnet publish -r win-x64 -c Release --self-contained

這時候會發布exe 文件.

如果想打包成一個exe文件,則運行命令:

// x86 

dotnet publish -r win-x86 -c Release /p:PublishSingleFile=true

// x64 

 dotnet publish -r win-x64 -c Release /p:PublishSingleFile=true

這時候輸出的文件大小比較大。

這時候有同學就想,有沒有辦法進行裁剪, 答案是肯定的 微軟這種事情肯定是考慮到的:

命令:

// x86 

dotnet publish -r win-x86 -c Release /p:PublishSingleFile=true /p:PublishTrimmed=true

// x64 

 dotnet publish -r win-x64 -c Release /p:PublishSingleFile=true /p:PublishTrimmed=true

 運行后需要的時間比沒有優化時間長,exe大小會縮小三分之一 

 

 

  


免責聲明!

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



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