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

unexpected compile error #6

Open
WeihanLi opened this issue Mar 28, 2023 · 3 comments
Open

unexpected compile error #6

WeihanLi opened this issue Mar 28, 2023 · 3 comments

Comments

@WeihanLi
Copy link
Owner

WeihanLi commented Mar 28, 2023

dotnet-exec "https://github.com/WeihanLi/SamplesInPractice/blob/56dda58920fa9921dad50fde4a8333581541cbd2/BalabalaSample/CorrelationIdSample.cs" --project "https://github.com/WeihanLi/SamplesInPractice/blob/56dda58920fa9921dad50fde4a8333581541cbd2/BalabalaSample/BalabalaSample.csproj" --wide false --debug
fail: dotnet-exec[0]
      Compile error:
      (24,40): error CS1929: 'ILoggingBuilder' does not contain a definition for 'AddSerilog' and the best extension method overload 'SerilogLoggerExtensions.AddSerilog(ILoggerFactory, ILogger?, bool)' requires a receiver of type 'Microsoft.Extensions.Logging.ILoggerFactory'

Version:
0.14.0+60527bb786298d0a812968d5129b802c38bf12ef

@WeihanLi
Copy link
Owner Author

WeihanLi commented Apr 2, 2023

Minimal sample to reproduce

// reference: nuget:WeihanLi.Common.Logging.Serilog

using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using WeihanLi.Common.Logging.Serilog;

namespace BalabalaSample;

public class Issue06Sample
{
    public static async Task MainTest()
    {
        var serviceCollection = new ServiceCollection()
                .AddLogging(builder => builder.AddSerilog())
            ;
        await using var provider = serviceCollection.BuildServiceProvider();
        provider.GetRequiredService<ILoggerFactory>()
            .CreateLogger("test")
            .LogInformation("Hello 1234");;
    }
}

@WeihanLi
Copy link
Owner Author

WeihanLi commented Apr 3, 2023

@WeihanLi
Copy link
Owner Author

WeihanLi commented Apr 8, 2023

Seemed it relates to the Microsoft.Extensions.Http package reference, it works when removing the Microsoft.Extensions.Http package reference, see commit a1dd0b5

image

Created an issue on roslyn issues dotnet/sdk#31691

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

No branches or pull requests

1 participant