Summary
Gets the service provider.
Syntax
[CakePropertyAlias(Cache = true)]
[CakeNamespaceImport("Microsoft.Extensions.DependencyInjection")]
public static IServiceProvider ServiceProvider(this ICakeContext context)
Examples
#module nuget:?package=Cake.MyService.Module&version=1.0.0
Task("MyTask")
.Does(() =>
{
var log = ServiceProvider.GetRequiredService<ICakeLog>();
log.Information("Hello from IoC");
var myService = ServiceProvider.GetRequiredService<IMyService>();
myService.DoSomething();
});
Attributes
| Type |
Description |
| CakePropertyAliasAttribute |
An attribute used to mark script property aliases.
|
| CakeNamespaceImportAttribute |
An attribute used to hint Cake about additional namespaces that need
to be imported for an alias to work. This attribute can mark an
extension method, the extension method class, or the assembly to provide a global set of imports.
|
Parameters
Return Value
| Type |
Description |
| IServiceProvider |
The service provider. |