0

I have been working on a logging project (class library), where we use Microsoft extensions logging logger instance and serilog as a logging provider to write the logs to json file. I have completed the project, now I'm testing it in my local console app. Everything was fine, except that recently I added few packages to my project and then used it's dll file reference in my console app again to test.

Issue: Now the problem is that when I build my console app it's not creating dll files of few packages whose references I have added to my project. But when I build my logging project there it creates all the dll files. More briefly, this is the section of proj file of my logging project:

 <PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
    <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
    <PackageReference Include="Microsoft.Extensions.Configuration.Xml" Version="7.0.0" />
    <PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
    <PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
    <PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
    <PackageReference Include="Serilog" Version="2.12.0" />
    <PackageReference Include="Serilog.Enrichers.Environment" Version="2.2.0" />
    <PackageReference Include="Serilog.Enrichers.Process" Version="2.0.2" />
    <PackageReference Include="Serilog.Enrichers.Thread" Version="3.1.0" />
    <PackageReference Include="Serilog.Expressions" Version="3.4.1" />
    <PackageReference Include="Serilog.Extensions.Logging" Version="7.0.0" />
    <PackageReference Include="Serilog.Formatting.Compact" Version="1.1.0" />
    <PackageReference Include="Serilog.Settings.AppSettings" Version="2.2.2" />
    <PackageReference Include="Serilog.Settings.Configuration" Version="7.0.0" />
    <PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
    <PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
    <PackageReference Include="Serilog.Sinks.RollingFile" Version="3.3.0" />
    <PackageReference Include="System.Configuration.ConfigurationManager" Version="7.0.0" />

`

So when I build my project it is creating dll files for all these references, but when I add my project's dll file as a reference to my console app and build it, it doesn't create few dll files like Serilog.Enrichers.Process, Serilog.Enrichers.Thread etc.

I have done clean and rebuild for both i.e., project and the console app, but still facing same issue.

Why is it my console app not creating those few dll files? I want the Serilog.Enrichers.Process and Thread dll to be created by console so that I can use them there to add properties to my logs.

I'm trying to configure my logger through the appsettings file of my console app, for which I want to have the dll files created by my console app. But it's not creating them. If I add a nuget package of the required dll again to console it will show exception as the project already has the assembly reference in it.

  • 3
    "when I add my project's dll file as a reference" It sounds like you are adding a reference to your class library's DLL rather than that library's project or a package. You want to do one of the latter to get the upstream dependencies. Adding it as a project reference is going to be the fastest to get up and running but it isn't very portable if that's a concern. – Luke Jun 13 '23 at 11:54
  • I agree Luke: create a package for your lib and deploy it on some package-server like nuget.org, Azure Artifacts or whatever. Then you can reference that package and get all its upstream dependencies. – MakePeaceGreatAgain Jun 13 '23 at 12:22

0 Answers0