c# Winform发布成独立文件

改造前: 

通过发布页面,修改部署模式为独立,输出文件目录没有完全包含所有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>

发布文件,输出目录:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值