Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement custom logger support for MSBuild #702

Closed
tomasaschan opened this issue Feb 22, 2016 · 1 comment
Closed

Implement custom logger support for MSBuild #702

tomasaschan opened this issue Feb 22, 2016 · 1 comment
Milestone

Comments

@tomasaschan
Copy link

MSBuild has the option of registering custom loggers, via the /logger:foo switch. This can be utilized through something like this today (this is in use in our build script):

MSBuild(solutionPath, settings => 
{
    settings.Configuration = configuration;

    if (EnvironmentVariable("BUILD_DEFINITIONNAME") != null) // this only happens on TFS
    {
        settings.ArgumentCustomization = arguments =>
        {
            arguments.Append(string.Format(
                "/logger:{0}\\Agent\\Worker\\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll",
                EnvironmentVariable("AGENT_HOMEDIRECTORY")));
            return arguments;
        };
    }
});

This is required to get "nice" output on TFS builds, so the web UI shows a list of errors rather than just "MSBuild failed" (see this SO question for an example).

It would be nice if this was available in a less roundabout way, e.g. through a property directly on MSBuildToolSettings, maybe something like this:

MSBuild(solutionPath, settings =>
{
    settings.Configuration = configuration;
    settings.Loggers.Add(/* long path to dll omitted */);
}
@cpx86
Copy link
Contributor

cpx86 commented Aug 29, 2016

I'm interested in fixing this if no one else is working on it yet.

The idea I have is basically the same as for adding/setting properties. MSBuildSettings would be extended with a Loggers property. Adding to this list would be done via an extension method WithLogger, taking the assembly name and optionally the class name or parameters for the logger. So the usage would be like this:

MSBuild(solutionPath, settings =>
{
    settings
        .WithLogger("MyLoggerAssembly1.dll", "MyLoggerClass1", "SomeParams")
        .WithLogger("MyLoggerAssembly2.dll", "MyLoggerClass2", "SomeParams");
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants