.net 8 WPF发布程序只生成exe
右击项目选择发布
配置发布信息
修改FolderProfile.pubxml文件内容
点击查看代码
<Project>
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>Any CPU</Platform>
<PublishDir>bin\Release\net8.0-windows\publish\win-x64\</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<_TargetId>Folder</_TargetId>
<TargetFramework>net8.0-windows</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<SelfContained>true</SelfContained>
<PublishReadyToRun>false</PublishReadyToRun>
<PublishSingleFile>true</PublishSingleFile>
<IncludeAllContentForSelfExtract>true</IncludeAllContentForSelfExtract>
<_SuppressWpfTrimError>true</_SuppressWpfTrimError>
<TrimMode>partial</TrimMode>
<SelfContained>true</SelfContained>
</PropertyGroup>
</Project>
1. 添加依赖项不显示依赖dll <IncludeAllContentForSelfExtract>true</IncludeAllContentForSelfExtract>
2. 不显示WPF错误 <_SuppressWpfTrimError>true</_SuppressWpfTrimError>
修改完成保存xml文件点击发布
在发布文件夹下查看内容如下图:
生成的pdb文件可删除