方式一:強烈推薦,能獨立運行,依賴DLL也會生成出來,支持無安裝環境也能處處運行
按win+R輸入cmd在控制檯中,進入項目可見bin的目錄下執行以下命令:
dotnet publish -r win10-x64 /p:PublishSingleFile=true
執行效果:html
項目目錄:markdown
生成的exe,依賴的全部dll都在publish文件夾裏面,如此此exe程序就能夠打包處處運行了,而不用安裝運行環境了app
轉載自:
https://blog.lindexi.com/post/dotnet-core-發佈只有一個-exe-的方法.htmlpost
方式二:(不推薦)
修改項目的csproj文件內容,加入atom
<RuntimeIdentifier>win10-x64</RuntimeIdentifier>
變成:.net
<PropertyGroup> <OutputType>Exe</OutputType> <TargetFramework>netcoreapp2.0</TargetFramework> <RuntimeIdentifier>win10-x64</RuntimeIdentifier> </PropertyGroup>
打開Windows PowerShell
進入項目根目錄命令
cd D:\項目\TankQiandaoWx\TankQiandaoWx\TankQiandaoWx
在項目根目錄執行命令:
運行程序
dotnet run -p TankQiandaoWx.csprojcode
發佈exe
dotnet publish TankQiandaoWx.csprojhtm
轉載:
https://www.cnblogs.com/linezero/p/nightlynetcore2.htmlblog