Aicrosoft.Extensions.Hosting
1.2.1-dev5-1115
This is a prerelease version of Aicrosoft.Extensions.Hosting.
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Aicrosoft.Extensions.Hosting --version 1.2.1-dev5-1115
NuGet\Install-Package Aicrosoft.Extensions.Hosting -Version 1.2.1-dev5-1115
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="Aicrosoft.Extensions.Hosting" Version="1.2.1-dev5-1115" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Aicrosoft.Extensions.Hosting --version 1.2.1-dev5-1115
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Aicrosoft.Extensions.Hosting, 1.2.1-dev5-1115"
#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.
// Install Aicrosoft.Extensions.Hosting as a Cake Addin #addin nuget:?package=Aicrosoft.Extensions.Hosting&version=1.2.1-dev5-1115&prerelease // Install Aicrosoft.Extensions.Hosting as a Cake Tool #tool nuget:?package=Aicrosoft.Extensions.Hosting&version=1.2.1-dev5-1115&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
How to use Aicrosoft.Extensions.Hosting
How to use
- add pakcage
NLog.Extensions.Logging
- add nlog.config
- chanage the program code and add extesion of host
Program.cs file
<details> <summary>The Application start</summary>
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using NLog;
var start = Environment.TickCount64;
var logger = LogManager.GetCurrentClassLogger();
logger.Trace($"Loggger was created TimeElapsed:{Environment.TickCount64 - start} ms");
try
{
start = Environment.TickCount64;
logger.Trace($"Begin Build Host Envirment ...");
using IHost host = Host.CreateDefaultBuilder(args)
.ConfigureAppConfiguration((host, configuration) =>
{
configuration.Sources.Clear();
configuration.AddCommandLine(args);
})
//.AddCurrentApplication() //Add current application a series of configuartion.
.Build();
logger.Trace($"End Build. TimeElapsed:{Environment.TickCount64 - start} ms");
await host.RunAsync();
return 0;
}
catch (Exception ex)
{
logger.Error(ex, "Build and run IHost has a exception");
return -9;
}
finally
{
LogManager.Shutdown();
}
</details>
IHostExtensions.cs file
<details> <summary>The Application's Host Extensions </summary>
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using NLog.Extensions.Logging;
internal static class IHostExtensions
{
/// <summary>
/// Add current application a series of configuartion.
/// </summary>
/// <param name="hostBuilder"></param>
/// <returns></returns>
public static IHostBuilder AddCurrentApplication(this IHostBuilder hostBuilder)
{
hostBuilder
.ConfigAppSetting()
.ConfigServices()
.ConfigureLogging()
.UseAop()
//.UseAopDI()
;
return hostBuilder;
}
/// <summary>
/// DI register
/// </summary>
/// <param name="hostBuilder"></param>
private static IHostBuilder ConfigServices(this IHostBuilder hostBuilder)
{
hostBuilder.ConfigureServices((hostContext, services) =>
{
//Auto register
services.AddService(typeof(Startup).Assembly);
////MS register.
//services.AddTransient<IDemo, DemoService>();
//services.AddTransient<IAutoDeployService, AutoDeployService>();
services.AddHostedService<Startup>();
});
return hostBuilder;
}
/// <summary>
/// config.json register
/// </summary>
/// <param name="hostBuilder"></param>
private static IHostBuilder ConfigAppSetting(this IHostBuilder hostBuilder)
{
hostBuilder
.ConfigureAppConfiguration((hostContext, configuration) =>
{
var env = hostContext.HostingEnvironment;
configuration
.AddJsonFile("./config.json")
.AddJsonFile($"./config.{env.EnvironmentName}.json", true, true);
;
})
.ConfigureServices((hostContext, services) =>
{
var config = hostContext.Configuration;
services.Configure<DeploySettingOption>(config.GetSection(DeploySettingOption.SectionName));
});
return hostBuilder;
}
/// <summary>
/// nlog replace
/// </summary>
/// <param name="hostBuilder"></param>
/// <returns></returns>
private static IHostBuilder ConfigureLogging(this IHostBuilder hostBuilder)
{
hostBuilder.ConfigureLogging(loggingBuilder =>
{
//configure Logging with NLog
loggingBuilder.ClearProviders();
loggingBuilder.SetMinimumLevel(LogLevel.Trace);
loggingBuilder.AddNLog();
});
return hostBuilder;
}
}
</details>
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net6.0
- Aicrosoft.Extensions (>= 1.2.1-dev5-1115)
- JetBrains.Annotations (>= 2022.1.0)
- Microsoft.Extensions.Hosting (>= 6.0.1)
NuGet packages (9)
Showing the top 5 NuGet packages that depend on Aicrosoft.Extensions.Hosting:
Package | Downloads |
---|---|
Aicrosoft.Extensions.AspectCore
Package Description |
|
Aicrosoft.Extensions.Mvc
Package Description |
|
Aicrosoft.Extensions.Swagger
Package Description |
|
Aicrosoft.Extensions.NLog
Package Description |
|
Aicrosoft.Scheduling
A multifunctional and extensible task scheduling framework |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
8.5.0 | 133 | 10/12/2024 |
8.3.0 | 169 | 9/10/2024 |
8.2.0 | 146 | 8/7/2024 |
6.4.0 | 548 | 11/20/2023 |
6.3.2 | 320 | 11/1/2023 |
6.2.1 | 329 | 8/25/2023 |
6.1.7 | 358 | 7/25/2023 |
6.1.5 | 536 | 3/13/2023 |
6.1.4 | 463 | 3/11/2023 |
6.1.3 | 532 | 2/21/2023 |
6.1.1 | 553 | 12/1/2022 |
6.1.1-beta.221203.1 | 183 | 12/3/2022 |
1.2.1-dev6-1129 | 689 | 11/29/2022 |
1.2.1-dev5-1115 | 200 | 11/29/2022 |
1.2.1-dev4-1114 | 224 | 11/14/2022 |
1.0.0 | 173 | 5/17/2023 |
0.2.1.1 | 547 | 11/10/2022 |
0.2.1-dev2-1110 | 214 | 11/10/2022 |
Quick and easy develop the dotnet