改造前:
通过发布页面,修改部署模式为独立,输出文件目录没有完全包含所有dll
改造后:
通过修改项目文件方式
修改csproj前:
<PropertyGroup><OutputType>WinExe</OutputType><TargetFramework>net6.0-windows</TargetFramework><Nullable>enable</Nullable><UseWindowsForms>true</UseWindowsForms><ImplicitUsings>enable</ImplicitUsings></PropertyGroup>
修改csproj后:
<PropertyGroup><OutputType>WinExe</OutputType><TargetFramework>net6.0-windows</TargetFramework><Nullable>enable</Nullable><UseWindowsForms>true</UseWindowsForms><ImplicitUsings>enable</ImplicitUsings><!-- 启用单文件发布 --><PublishSingleFile>true</PublishSingleFile><!-- 包含.NET运行时(独立部署) --><SelfContained>true</SelfContained><!-- 指定运行时环境 --><RuntimeIdentifier>win-x64</RuntimeIdentifier><!-- 启用文件压缩 --><EnableCompressionInSingleFile>true</EnableCompressionInSingleFile><!-- 强制包含图中未打包的WPF原生DLL,如D3DCompiler_47_cor3.dll、PenImc_cor3.dll、wpfgfx_cor3.dll、vcruntime140_cor3.dll、PresentationNative_cor3.dll等 --><IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract></PropertyGroup>
发布文件,输出目录: