Skip to main content
.NETStandard2.0

This package provides a Serilog sink that redirects events to MSBuild. It is useful when an MSBuild task calls code that uses Serilog. Despite the package depending on MSBuild 17, it will work on versions after 15. When using this package, MSBuild's assemblies are not copied, which is not a problem for custom task assemblies.

Published
Dec 8, 2024
1y ago
Total Downloads
26.2K
26,201

Install

dotnet add package Serilog.Sinks.MSBuild --version 1.6.0
ProductVersions
.NET Standard
netstandard2.0

README

A Serilog sink for MSBuild

License: Apache License 2.0 Nuget package: Serilog.Sinks.MSBuild

How to use

using Microsoft.Build.Utilities;
using Serilog;

public class MyTask: Task {

    public override bool Execute() {
        using (ILogger _logger = new LoggerConfiguration().WriteTo.MSBuild(this).CreateLogger()) {
            _logger.Information("Hello from my custom Serilog-powered task");
            // [...]
            return true;
        };
    }
}

Important properties

Some Serilog properties carry meaningful information for MSBuild, like message code, file and line and column numbers.

They are covered in Serilog.Sinks.MSBuild.MSBuildMessages.

Maintainer(s)

Changes from Previous Version

v1.5.0v1.6.0
Removed Frameworks
.NETFramework4.7.2
Removed Dependencies
Microsoft.Build.Framework(.NETFramework4.7.2)
Microsoft.Build.Utilities.Core(.NETFramework4.7.2)
Serilog(.NETFramework4.7.2)

Adoption Assessment

Assess this package against its supported frameworks, license, maintenance signals and dependency graph before making it a project standard.

Compatibility metadata lists 1 target framework; confirm the exact target used by your application.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.