.Net Core控制台生成exe能独立运行

.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>

打开Windows PowerShell
进入项目根目录命令
cd D:项目TankQiandaoWxTankQiandaoWxTankQiandaoWx
在项目根目录执行命令:
运行程序
dotnet run -p TankQiandaoWx.csproj

发布exe
dotnet publish TankQiandaoWx.csproj

转载:
https://www.cnblogs.com/linezero/p/nightlynetcore2.html

出处:https://blog.csdn.net/u011511086/article/details/80419676

原文地址:https://www.cnblogs.com/mq0036/p/11157704.html