学无先后达者为师!
不忘初心,砥砺前行。

路遥工具箱 .NET 6.0 独立部署时优化目录结构

在将一个 .NET CORE \ .NET 5.0 \ .NET 6.0 程序进行独立部署发布时,会在发布目录产生很多系统类库,导致目录非常不简洁。这给寻找入口程序造成了困难,特别是路遥工具箱这种绿色软件,不会在开始菜单、系统桌面创建快捷方式,如此多的文件直接将小白用户劝退。

独立部署时会产生大量的系统文件,难以找到应用程序的入口。

使用 NetCoreBeauty 优化目录结构

NetCoreBeauty moves .NET Core app runtime components and dependencies into a sub-directory to make it beautiful.

NetCoreBeauty 会将 .NET Core 软件的运行时组件和依赖移动到一个子目录中,让发布文件看起来更简洁漂亮。

路遥工具箱使用 NetCoreBeauty 优化了目录结构

NetCoreBeauty 的开源地址在:https://github.com/nulastudio/NetCoreBeauty

如何使用 NetCoreBeauty

NetCoreBeauty 只适用于独立部署发布模式的程序。

为项目添加 Nuget 引用

dotnet add package nulastudio.NetCoreBeauty

编辑项目配置文件(*.csproj)应该和下面的代码类似:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp2.1</TargetFramework>
    <!-- beauty into sub-directory, default is libs, quote with "" if contains space  -->
    <!-- 要移动到字母名称,默认是 libs 目录,如果需要包含空格,请用双引号括起来 -->
    <BeautyLibsDir>libraries</BeautyLibsDir>
    <!-- 设置一些你不想被移动或者不能被移动到子目录的文件名,支持匹配。 -->
    <!-- dlls that you don't want to be moved or can not be moved -->
    <!-- <BeautyExcludes>dll1.dll;lib*;...</BeautyExcludes> -->
	<!-- 最终用户不会使用到的文件,可以在这里配置隐藏掉。 -->
    <!-- dlls that end users never needed, so hide them -->
    <!-- <BeautyHiddens>hostfxr;hostpolicy;*.deps.json;*.runtimeconfig*.json</BeautyHiddens> -->
	<!-- 如果不想执行移动操作,可以设置为 True -->
    <!-- set to True if you want to disable -->
    <DisableBeauty>False</DisableBeauty>

    <!-- set to True if you don't want to generate NetCoreBeauty flag file -->
    <!-- do not beauty twice since there is no flag file to determine if beauty already -->
    <NoBeautyFlag>False</NoBeautyFlag>
    <ForceBeauty>False</ForceBeauty>
    <!-- <BeautyAfterTasks></BeautyAfterTasks> -->
    <!-- set to True if you want to disable -->
    <DisablePatch>False</DisablePatch>
    <!-- valid values: Error|Detail|Info -->
    <BeautyLogLevel>Error</BeautyLogLevel>
    <!-- 设置仓库镜像,如果你不能链接到 GitHub 的话可以采用该设置。推荐大陆用户打开这个配置。 -->
	<!-- set to a repo mirror if you have troble in connecting github -->
    <!-- <GitCDN>https://gitee.com/liesauer/HostFXRPatcher</GitCDN> -->
    <!-- <GitTree>master</GitTree> -->
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="nulastudio.NetCoreBeauty" Version="1.2.9.3" />
  </ItemGroup>

</Project>

以上中文翻译来由码农很忙提供。

在你使用 dotnet publish 命令或者 Visual Studio 发布时,移动工作将自动进行。

官方提供了一个测试项目,可以在这里看到源代码:

https://github.com/nulastudio/NetCoreBeauty/tree/master/NetCoreBeautyNugetTest

路遥工具箱下载地址

如果你对路遥工具箱感兴趣,可以在这里下载:

https://www.coderbusy.com/luyao-toolkit

赞(3) 打赏
未经允许不得转载:码农很忙 » 路遥工具箱 .NET 6.0 独立部署时优化目录结构

评论 抢沙发

给作者买杯咖啡

非常感谢你的打赏,我们将继续给力更多优质内容,让我们一起创建更加美好的网络世界!

支付宝扫一扫

微信扫一扫

登录

找回密码

注册