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