Azrng.ConsoleApp.DependencyInjection
1.3.2
dotnet add package Azrng.ConsoleApp.DependencyInjection --version 1.3.2
NuGet\Install-Package Azrng.ConsoleApp.DependencyInjection -Version 1.3.2
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Azrng.ConsoleApp.DependencyInjection" Version="1.3.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Azrng.ConsoleApp.DependencyInjection" Version="1.3.2" />
<PackageReference Include="Azrng.ConsoleApp.DependencyInjection" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Azrng.ConsoleApp.DependencyInjection --version 1.3.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Azrng.ConsoleApp.DependencyInjection, 1.3.2"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Azrng.ConsoleApp.DependencyInjection@1.3.2
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Azrng.ConsoleApp.DependencyInjection&version=1.3.2
#tool nuget:?package=Azrng.ConsoleApp.DependencyInjection&version=1.3.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Azrng.ConsoleApp.DependencyInjection
控制台依赖注入扩展
- 支持读取appsettings.json配置文件
- 默认使用了Serilog日志输出
构建方法
方式1: 简单方式,不需要依赖注入
var builder = new ConsoleAppServer(args);
await using var sp = builder.Build<TempService>();
await sp.RunAsync();
方式2: 注入通用配置
var builder = new ConsoleAppServer(args);
// 注入自定义配置
builder.Services.AddHttpClient();
await using var sp = builder.Build<UrlSortService>();
await sp.RunAsync();
Console.Read();
方式3: 委托方式注册服务
var builder = new ConsoleAppServer(args);
await using var sp = builder.Build<JsonTempService>(services =>
{
services.ConfigureDefaultJson();
});
await sp.RunAsync();
版本更新记录
- 1.3.2
- 发布正式版
- 1.3.2-beta3
- 移除Serilog相关包测试
- 1.3.2-beta2
- 引用.Net10正式包
- 1.3.2-beta1
- 适配.Net10
- 1.3.1
- 适配Azrng.Core的更新
- 1.3.0
- 支持Build重载,支持针对Service注入特定配置
- 1.2.0
- 支持将默认ILogger日志输出到本地文件
- 1.1.0
- 更新依赖项
- 1.0.1
- 读取环境变量需增加变量前缀:ASPNETCORE_
- 1.1.0-beta1
- 测试进一步缩小打包文件的大小
- 1.0.0
- 基础控制台依赖注入开发
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- Azrng.Core (>= 1.8.4)
- Microsoft.Extensions.Hosting (>= 10.0.0)
-
net8.0
- Azrng.Core (>= 1.8.4)
- Microsoft.Extensions.Hosting (>= 8.0.0)
-
net9.0
- Azrng.Core (>= 1.8.4)
- Microsoft.Extensions.Hosting (>= 9.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.3.2 | 569 | 12/1/2025 |
| 1.3.2-beta3 | 388 | 11/19/2025 |
| 1.3.2-beta2 | 265 | 11/12/2025 |
| 1.3.2-beta1 | 140 | 11/6/2025 |
| 1.3.1 | 176 | 7/7/2025 |
| 1.3.0 | 185 | 7/1/2025 |
| 1.2.0 | 167 | 5/9/2025 |
| 1.1.0 | 157 | 3/21/2025 |
| 1.1.0-beta1 | 131 | 2/18/2025 |
| 1.0.1 | 156 | 2/23/2025 |
| 1.0.0 | 152 | 2/17/2025 |