1. 程式人生 > >.Net Core 2.0 程式 ,編譯出exe可執行檔案方法

.Net Core 2.0 程式 ,編譯出exe可執行檔案方法

.Net Core 2.0 程式 用vs生成後無exe啟動項,如果需要生成exe執行檔案可以:

1.修改專案的csproj檔案內容

原始:

<PropertyGroup> 
	<OutputType>Exe</OutputType> 
	<TargetFramework>netcoreapp2.0</TargetFramework> 
</PropertyGroup>

修改後:(加入: <RuntimeIdentifier>win10-x64</RuntimeIdentifier>

<PropertyGroup> 
	<OutputType>Exe</OutputType> 
	<TargetFramework>netcoreapp2.0</TargetFramework> 
	<RuntimeIdentifier>win10-x64</RuntimeIdentifier> 
</PropertyGroup>

2.操作:

1.開啟Windows PowerShell

2.進入專案根目錄命令
cd C:\AAA

3.在專案根目錄執行命令:
執行
dotnet run -p AAA.csproj

釋出
dotnet publish AAA.csproj

操作完成後 在 publish 資料夾下可發現 exe 檔案