改造前:?
通過發布頁面,修改部署模式為獨立,輸出文件目錄沒有完全包含所有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>
發布文件,輸出目錄: