ASP.NET Core 是一个跨平台的高性能开源框架,用于生成基于云且连接 Internet 的新式应用程序。
可用于建立Web应用、 IoT物联网、移动后端等。
#! 安装工具
dotnet tool install -g csharprepl # csharp console playground
dotnet tool install -g dotnet-ef # dotnet ef database-migrations tool
dotnet tool install -g dotnet-trace # 监控.NET程序的GC; 获取所有进程: dotnet trace ps 诊断指定程序: dotnet gcmon -p 1024
#! 安装模板,创建项目
dotnet new console # Common/Console
dotnet new classlib # Common/Library
dotnet new web # Web/Empty
dotnet new webapi # Web/WebAPI
dotnet new mvc # Web/MVC
dotnet new sln # Solution
dotnet new globaljson # Config
dotnet new nugetconfig # Config
dotnet new webconfig # Config
dotnet new --install Microsoft.AspNetCore.SpaTemplates::* # install templates from official repository
dotnet new angular # 创建新的项目使用 SPA 模板
dotnet new react # Web/MVC/SPA
dotnet new reactredux # Web/MVC/SPA
dotnet new --install [path-to-repository] # install templates from src (exists *dotnet-templates.nuspec)
dotnet new avalonia.app # ui/xaml from https://github.com/AvaloniaUI/avalonia-dotnet-templates
dotnet new avalonia.mvvm # ui/xaml
dotnet new avalonia.usercontrol # ui/xaml
dotnet new avalonia.window # ui/xaml
dotnet new avalonia.resource # ui/xaml
dotnet new avalonia.styles # ui/xaml
... ... # dotnet new --help
# <PM> 从数据库至代码MODEL / DbFirst
PM> Install-Package Microsoft.EntityFrameworkCore.SqlServer
PM> Install-Package Microsoft.EntityFrameworkCore.Tools
# 脚手架工具Scaffold 用于生成模板代码
# Scaffold-DbContext {ConnectionString} Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models/Entities -Context {DbName}DbContext -ContextDir Models -DataAnnotations -Force
PM> Scaffold-DbContext "Server=(localdb)\mssqllocaldb;Database=DbName;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models
# <PM> 从代码MODEL至数据库,名称“Initial”是任意的,用于对迁移文件进行命名 / CodeFirst
PM> Add-Migration Initial # 添加迁移版本的名称
PM> Update-Database # 迁移至数据库
PS> dotnet ef migrations -h # 使用命令行CMD或PowerShell
PS> dotnet ef migrations add Initial
PS> dotnet ef database update
# <PM> WEB页面与代码生成器
PM> Install-Package Microsoft.VisualStudio.Web.CodeGeneration.Design -Version 2.0.3
PM> dotnet aspnet-codegenerator razorpage -m Movie -dc MovieContext -udl -outDir Pages\Movies --referenceScriptLibraries
# <PM> Desktop桌面跨平台应用
PM> Install-Package Avalonia # ui/xaml from https://github.com/AvaloniaUI/Avalonia
PM> Install-Package Avalonia.Desktop
# 查看在线.NET Core项目依赖包
PS> dotnet nuget locals all --list
# 复制 http-cache: C:\Users\Administrator\AppData\Local\NuGet\v3-cache
# 复制 global-packages: C:\Users\Administrator\.nuget\packages\
# 离线还原.NET Core项目依赖包
PS> dotnet restore --source C:\Users\Administrator\.nuget\packages\ # 离线还原NuGet依赖包
PS> dotnet run --no-restore # 运行项目(不还原NuGet依赖包)
PS> dotnet build --no-restore # 生成项目(不还原NuGet依赖包)
PS> dotnet build ./*.csproj -c Release # 生成项目(要还原NuGet依赖包) 接下来,发布项目。
PS> dotnet publish -c Release /p:PublishSingleFile=true /p:PublishTrimmed=true -f net5.0 -r linux-x64 -o "./bin/Release/net5.0/publish/linux-x64"
PS> dotnet publish -c Release /p:PublishSingleFile=false /p:PublishTrimmed=false -f net5.0 -r win-x64 -o "./bin/Release/net5.0/publish/win-x64"
PS> dotnet publish ./*.csproj -c Release -r win-x64 -o "./bin/Release/net5.0/publish/win-x64"
# 安装
docker run --name nuget-server -itd -p 8880:80 --restart=always --env-file baget.env -v "$(pwd)/baget-data:/var/baget" loicsharma/baget:latest
# 配置 baget.env # ApiKey=
# 打包
dotnet pack
# 发布
dotnet nuget push -s http://nuget.xxx.com/v3/index.json -k {ApiKey} {PackageId}.{Version}.nupkg
# 使用 gRPC [ dotnet --version >= v3.0 ] 生命周期>
# Client(发送请求)-> Client stub(压缩/解压)-> Client RPC Transfer(发送/接收)
# -> Server RPC Transfer(接收/发送)-> Server stub(解压/压缩)-> Server(处理/响应)
> dotnet tool install -g dotnet-grpc # 安装 dotnet gRPC CLI工具(最新版)
> dotnet new grpc -n gRPC.Services # 新建Server工程< *.proto文件<: option csharp_namespace="gRPC.Services"
> dotnet-grpc add-file ../gRPC.Protos/*.proto -s Serve # 引入生成的protobuf文件到工程中\Serve\生成C#代码
# 新建服务类 > 实现gRPC接口(继承) > 配置grpc服务类: endpoints.MapGrpcService<SmsService>();
> dotnet add package Google.Protobuf # 新建Client工程依赖
> dotnet-grpc add-file ../gRPC.Protos/*.proto -s Client # 引入生成的protobuf文件到工程中\Client\生成C#代码
# 使用 MsgPack [ dotnet --version >= v2.1 ] 项目中安装>
> Install-Package MessagePack
> Install-Package MessagePackAnalyzer
> Install-Package MessagePack.ImmutableCollection
> Install-Package MessagePack.ReactiveProperty
> Install-Package MessagePack.UnityShims
> Install-Package MessagePack.AspNetCoreMvcFormatter
-
开源的 应用框架
-
开源的 扩展框架
- ASP.NET Core 综合应用
ABAC
基于属性的访问控制(Attribute-Based Access Control)RBAC
基于角色的访问控制(Role-Based Access Control)→MongoDB
→goRBAC
→AuthBoss
CBAC
基于声明的访问控制(Claim-Based Access Control)身份认证
Claim
申明身份的片段数据→ClaimsIdentity
单个身份信息→ClaimsPrincipal
主体身份的集合
访问控制(casbin)
→资源命名(upspin)
→准入控制(AdmissionControl)
访问权限
Asp.Net Core Identity、Identity Server 4
- Asp.Net Core 混合全球化与本地化支持
- EntityFramework Core 2.x/3.x (ef core) 在迁移中自动生成数据库表和列说明
- 应用程序容器化
- 服务注入Ioc Autofac
- 切面编程Aop AspectCore-Framework
- 序列化Json Json.Net
- 映射模型 AutoMapper
- 高性能存储 microsoft.FASTER、FASTER.KV replace ConcurrentDictionary、FASTER.Log unique hybrid records
- 日志 NLog、Exceptionless
- 缓存 EasyCaching
- 事件总线 CAP
- 二维码 QRCoder
- 开源OCR .Net wrapper for tesseract-ocr
- 开源Office组件
NPOI
- 破解Office组件
Spire
推荐
、破解Office组件Aspose
推荐
- 破解Office组件
DevExpress(推荐)
,下载DevExpress
for.doc,docx,txt,rtf,mht,odt,xml,epub,html
,excel
,pdf
- 分布式主键ID生成器(雪花漂移算法500W/s)、Id生成器 ECommon.Utilities.ObjectId
- Linq扩展 System.Linq.Dynamic.Core
- 科学计算 MathNet
- 定时任务 Quartz.Net
- 包装调用本机 Windows API
- 单元测试/库 Verify
- 基准/压测/库 Powerful .NET library for benchmark
- 基准/压测/工具 NBomber
- ASP.NET Core 综合应用
-
开源的 Sql ORM
-
开源的 跨语言+跨平台+远程调用(RPC,gRPC等)
- NATS - 开源消息系统
- ZeroMQ 跨语言,LGPLed解决方案
- Hprose 跨语言,跨平台,无侵入式,高性能动态远程对象调用引擎库
- microsoft.ClearScript supports JavaScript (via V8 and JScript) and VBScript, Examples, Tutorial
-
实时应用
-
界面
UI桌面软件
(WinFrom、WPF、DotnetCore^3)- 开源WPF控件库
MaterialDesignInXAML
、PanuonUI
、HandyControl
、Beautiful WPF Control UI - .NET Core Blazor 官方文档
- Ant Design 的 Blazor 组件库
推荐
服务于企业级后台产品 - Bootstrap 的 Blazor 组件库
推荐
、官方文档 - DevExpress 控件库,工具,框架
推荐
、示例代码 安装
制作 WiX Toolset & Visual Studio Extension部署
发布 ClickOnce 应用程序工具
Advanced Installer v18.8 破解版工具
setup factory v9.5.3 汉化版
- 开源WPF控件库
-
物联网
应用 -
代码
生成器 -
扩展
Microsoft Visual Studio -
快速开发
解决方案
- Senparc.Weixin .NET SDK
- Senparc.Weixin .Tool WeChatSampleBuilder
- Senparc SCF框架:模块化SenparcCoreFramework
- Senparc SCF模块:微信管理后台
学无先后达者为师!技术改变生活!.Net群1600800,嵌入式物联网群1600838
旨在提升小型团队的开发输出能力,由常用公共操作类(工具类)、分层架构基类、Ui组件,第三方组件封装,第三方业务接口封装,
配套代码生成模板,权限等组成。
一个快速响应,移动优先的符合现代UI设计和SOLID架构的强力开发框架;包含登录,身份验证,用户/角色/权限管理,本地化,
设置系统,审计日志记录,多租户,UI组件,异常处理系统等功能。
- 类型反射
// 反射泛型方法,批量处理 Providers 继承于 AuthorizationProvider
foreach (var t in GetType().GetAssembly().GetTypes().Where(t => t.IsPublic && t.IsClass
&& t.IsSubclassOf(typeof(Abp.Authorization.AuthorizationProvider))))
Configuration.Authorization.Providers.GetType().GetMethods().FirstOrDefault(i => i.Name == "Add")
?.MakeGenericMethod(t).Invoke(Configuration.Authorization.Providers, new object[] { });
- 同步
Synchronous
、异步Asynchronous
- 通信方法
REST
<RPC
<Message Event Hub
dotnet presentations conf,Easy.MessageHub
- 消息事件总线
Message Event Hub
- 后台任务/长时间任务
Long-Running Work
(one producer, one consumer) - 负载平衡/自动缩放生产
Load Leveling
(multiple producers, one consumer) - 负载均衡/自动缩放消费
Load Balancing and Auto Scaling
(multiple producers, multiple consumers) - 发布订阅
Publish-Subscribe
(one producer, multiple consumers) - 发布分流
Partitioning
(one producer, multiple consumers) - 多路复用/排它性消费
Multiplexing with Exclusive Consumers
(multiple producers, multiple consumers) - 状态处理
Stateful Processing
- 稀疏连通性
Sparse Connectivity
- 后台任务/长时间任务