撰寫C# Console是否都會產生以下 一堆哩哩扣扣的檔案呢?看起來很瞎 ![image](https://hackmd.io/_uploads/r1P3ySW_6.png) net core 6有可以打包輸出單一exe的功能囉~~~ 所以這時候我們要去專案檔設定 ```java <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <TargetFramework>net6.0</TargetFramework> <ImplicitUsings>enable</ImplicitUsings> <Nullable>enable</Nullable> <PublishSingleFile>true</PublishSingleFile><!--只產出一個exe--> </PropertyGroup> <PropertyGroup> <PublishTrimmed>true</PublishTrimmed> <!--是否壓縮--> </PropertyGroup> <ItemGroup> <PackageReference Include="NPOI" Version="2.6.2" /> </ItemGroup> </Project> ``` 此時再重新發布 ```java dotnet publish -r win-x64 -c Release ``` Done~讚ㄉ ![image](https://hackmd.io/_uploads/SJxXVHZda.png) 當然你也可以這樣做~也可以達到同樣的效果 ```java dotnet publish -r win-x64 -c Release /p:PublishSingleFile=true ```