安装vscode
安装dotnet
配置nuget源 dotnet nuget add source https://api.nuget.org/v3/index.json -n nuget.org
修改了源:
C:\Users\guokeyuan\AppData\Roaming\NuGet\NuGet.Config
https://repo.huaweicloud.com/repository/nuget/v3/index.json
安装dotnet-ef工具
dotnet tool install --global dotnet-ef
终端新建C#项目:
dotnet new winforms -n MyWinFormsApp
cd .\MyWinFormsApp
code .
开始开发:
安装包
dotnet add package Newtonsoft.Json
dotnet add package Microsoft.Windows.Compatibility
dotnet add package Microsoft.Extensions.Configuration
打包运行:
dotnet clean
dotnet build
dotnet run
打包exe:
dotnet publish -c Release -r win-x64 --self-contained
可以直接拷贝 \bin\Debug\net8.0-windows 目录下所有文件,执行exe即可使用。