代码
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<!--定义为单文件 -->
<PublishSingleFile>true</PublishSingleFile>
<!--包含运行环境,客户端不需要安装Netcore-->
<SelfContained>true</SelfContained>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<!--exe包含pdb调试文件-->
<DebugType>embedded</DebugType>
<!--是否启用压缩,,原本88MB,能缩小到43MB-->
<EnableCompressionInSingleFile>true</EnableCompressionInSingleFile>
<!--指定IncludeAllContentForSelfExtract在运行可执行文件之前提取所有文件,包括托管程序集。这可能有助于解决罕见的应用程序兼容性问题。-->
<!--这就是把所有其他的dll文件都放进去-->
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
</PropertyGroup>
后续
经过测试,发现wpf无法很好的集成oc,所以暂时不打算使用wpf作为桌面软件开发的框架了。