.Net Core控制台生成exe能独立运行,依赖文件都单独生成在一个publish文件夹里
方式一:强烈推荐,能独立运行,依赖DLL也会生成出来,支持无安装环境也能到处运行
按win+R输入cmd在控制台中,进入项目可见bin的目录下执行如下命令:
dotnet publish -r win10-x64 /p:PublishSingleFile=true
执行效果:
项目目录: 生成的exe,依赖的所有dll都在publish文件夹里面,如此此exe程序就可以打包到处运行了,而不用安装运行环境了转载自:
https://blog.lindexi.com/post/dotnet-core-发布只有一个-exe-的方法.html
方式二:(不推荐)
修改项目的csproj文件内容,加入
<RuntimeIdentifier>win10-x64</RuntimeIdentifier>
变成:
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
<RuntimeIdentifier>win10-x64</RuntimeIdentifier>
</PropertyGroup>