zoukankan      html  css  js  c++  java
  • VS2019(NET Core 3.0)发布单文件可执行程序

    NET Core 3.0 发布单文件可执行程序

    两种方法。

    一、右击vs编辑项目文件,增加PublishSingleFile节点配置,代码如下:

      <Project Sdk="Microsoft.NET.Sdk">
    
      <PropertyGroup>
      <RuntimeIdentifier>win10-x64</RuntimeIdentifier>
      <PublishSingleFile>true</PublishSingleFile>
      <OutputType>Exe</OutputType>
      <TargetFramework>netcoreapp3.0</TargetFramework>
      </PropertyGroup>
    
      <ItemGroup>
      <PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
      </ItemGroup>
    
      </Project>
    

    然后右击点击“发布”按钮即可。文件比较大,随便建立一个winform程序发布之后149M。发布的 

    win10-x64 种类型的,测试在 windows server 2008 上也可以运行。第一次运行有点慢。

    <PublishTrimmed>true</PublishTrimmed>

    剪裁未使用的程序集来减小应用的大小,使用反射或相关动态功能的应用程序慎用

    RuntimeIdentifier 参考:
    https://www.cnblogs.com/frankyou/p/5630998.html

    • Windows 7
      • win7-x64
      • win7-x86
    • Windows 8
      • win8-x64
      • win8-x86
    • Windows 10
      • win10-x64
      • win10-x86

    二、在项目目录下执行如下命令:
    Windows
      dotnet publish -r win10-x64 /p:PublishSingleFile=true
    maxOS
      dotnet publish -r osx-x64 /p:PublishSingleFile=true
    Linux
      dotnet publish -r linux-x64 /p:PublishSingleFile=true

  • 相关阅读:
    LeetCode-389-找不同
    xml配置与使用
    curl使用
    php中JPGraph入门配置与应用
    php开发通用采集程序
    adodb配置与使用
    swfupload上传
    ZendFramework使用中常见问题
    memcache配置与使用
    第四章 供给与需求的市场力量
  • 原文地址:https://www.cnblogs.com/onecool/p/11737852.html
Copyright © 2011-2022 走看看