zoukankan      html  css  js  c++  java
  • dotnet core瘦身发布

    需要安装nuget包Microsoft.Packaging.Tools.Trimming
    然后利用如下命令发布
    dotnet publish -r win10-x64 -c release --self-contained true /p:TrimUnusedDependencies=true
    发布完成之后,实际上还是有不少dll文件,只不过由原来的200多个减少了70多个。
     
    然后还有个瘦身的方法
    项目地址https://github.com/dgiagio/warp
    国内这毛线网可能有点慢

    关于windows摘录如下

    Windows

    Create a simple console application

    PS C:UsersDiegoDevel> mkdir myappPS C:UsersDiegoDevel> cd myappPS C:UsersDiegoDevelmyapp> dotnet new consolePS C:UsersDiegoDevelmyapp> dotnet runHello World!PS C:UsersDiegoDevelmyapp>

    Publish the application with native installer for win10-x64 runtime

    PS C:UsersDiegoDevelmyapp> dotnet publish -c Release -r win10-x64

    The application should be published to bin/Release/netcoreapp2.1/win10-x64/publish/

    Download warp-packer

    If you save warp-packer in a directory in your PATH, you only need to download it once.

    PS C:UsersDiegoDevelmyapp> [Net.ServicePointManager]::SecurityProtocol = "tls12, tls11, tls" ; Invoke-WebRequest https://github.com/dgiagio/warp/releases/download/v0.3.0/windows-x64.warp-packer.exe -OutFile warp-packer.exe

    Create your self-contained application

    PS C:UsersDiegoDevelmyapp> .warp-packer --arch windows-x64 --input_dir bin/Release/netcoreapp2.1/win10-x64/publish --exec myapp.exe --output myapp.exe

    Run your self-contained application

    PS C:UsersDiegoDevelmyapp> .myapp.exeHello World!PS C:UsersDiegoDevelmyapp>

    More information about your self-contained application

    PS C:UsersDiegoDevelmyapp> "{0:N2} MB" -f ((Get-Item myapp.exe).Length / 1MB)28.51 MB


    坑爹的情况是,这个warp程序会一直下载不下来,然后尝试文档中提到的用power shell下载
    在powsershell 中执行如下语句
    [Net.ServicePointManager]::SecurityProtocol = "tls12, tls11, tls" ; Invoke-WebRequest https://github.com/dgiagio/warp/releases/download/v0.3.0/windows-x64.warp-packer.exe -OutFile warp-packer.exe
    孬好速度比浏览器要一点,下载完后,准备打包

    按照指令格式,拼装指令,示例如下,然后就可以将exe和DLL打包成1个exe了

    PS E:DijingToolsDijing.Update> .warp-packer.exe --arch windows-x64 --exec Dijing.Update.exe --input_dir
    .in elease etcoreapp2.1win10-x64publish --output Dijing.Update.exe


    然后测试一下exe,可以正常,这样部署的时候,就不用带很多程序了

    PS E:DijingToolsDijing.UpdateinDebug etcoreapp2.1publish> .Dijing.Update.exe http://zhcto.com/packa
    ges/106SP7fc10b15-8dd8-4ecc-ba02-f52a833b3783.zip
    文件夹E:DijingToolsDijing.UpdateinDebug etcoreapp2.1publish emp创建成功
    升级包开始下载
    升级包下载中...3833,157757,2%
    升级包下载中...13587,157757,8%
    升级包下载中...46063,157757,29%
    升级包下载中...71479,157757,45%
    升级包下载中...137015,157757,86%
    升级包下载中...140667,157757,89%
    升级包下载中...157757,157757,100%
    升级包下载完成
    检测到升级包已存在
    升级包解压完成
    升级文件遍历完成,文件个数为:5
    升级包文件覆盖完成
    临时文件夹删除完成

    程序启动成功 
    PS E:DijingToolsDijing.UpdateinDebug etcoreapp2.1publish> 



    还有一种CoreLR的东西,也可以瘦身,不过注入关系得自己写个表,就懒得弄了

  • 相关阅读:
    数据库字段太多,批量快速建立实体类方法(适合大量字段建立实体类)
    SQL service 中的 ”输入SQL命令窗口“ 打开了 “属性界面” 回到 ”输入SQL命令窗口“
    计算机软件编程英语词汇集锦
    编程常用英语词汇
    svn上传和下载项目
    当启动tomcat时出现tomcat setting should be set in tomcat preference page
    Implicit super constructor Object() is undefined for default constructor. Must define an explicit constructor
    eclipse中选中一个单词 其他相同的也被选中 怎么设置
    Spring Boot的@SpringBootApplication无法引入的问题
    最全的SpringCloud视频教程
  • 原文地址:https://www.cnblogs.com/willhuo/p/10586148.html
Copyright © 2011-2022 走看看