Azrng.ConsoleApp.DependencyInjection 1.3.1

dotnet add package Azrng.ConsoleApp.DependencyInjection --version 1.3.1
                    
NuGet\Install-Package Azrng.ConsoleApp.DependencyInjection -Version 1.3.1
                    
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.1" />
                    
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.1" />
                    
Directory.Packages.props
<PackageReference Include="Azrng.ConsoleApp.DependencyInjection" />
                    
Project file
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.1
                    
#r "nuget: Azrng.ConsoleApp.DependencyInjection, 1.3.1"
                    
#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.1
                    
#: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.1
                    
Install as a Cake Addin
#tool nuget:?package=Azrng.ConsoleApp.DependencyInjection&version=1.3.1
                    
Install as a Cake Tool

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.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 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 was computed.  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.

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.1 146 7/7/2025
1.3.0 148 7/1/2025
1.2.0 134 5/9/2025
1.1.0 135 3/21/2025
1.1.0-beta1 108 2/18/2025
1.0.1 120 2/23/2025
1.0.0 128 2/17/2025