title: Could not load file or assembly Microsoft.Extensions.Logging.Abstractions
body: <p>I'm using VS2019 Pro v16.3.5 </p>
  
  <p>I have a solution containing an Azure functions project which references several class library projects.</p>
  
  <p>The top-level project fails to compile with the following error:</p>
  
  <blockquote>
    <p>System.IO.FileNotFoundException: Could not load file or assembly
    'Microsoft.Extensions.Logging.Abstractions, Version=2.2.0.0,
    Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot
    find the file specified.</p>
  </blockquote>
  
  <p>The project does have a package reference: <em>PackageReference Include="Microsoft.AspNetCore.App"</em> and this framework includes the missing dll, so I don't know why it's having trouble.</p>
  
  <p>My thoughts are perhaps one of the referenced projects is depending on a different version but I don't see it.</p>
  
  <p>I did try explicitly referencing the package in the top-level project but this made no difference:</p>
  
  <pre><code>&lt;PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="2.2.0.0" /&gt;
  </code></pre>
  
  <p>Here is a current copy of the top-level csproj file:</p>
  
  <pre><code>&lt;Project Sdk="Microsoft.NET.Sdk"&gt;
    &lt;PropertyGroup&gt;
      &lt;TargetFramework&gt;netcoreapp2.2&lt;/TargetFramework&gt;
      &lt;AzureFunctionsVersion&gt;v2&lt;/AzureFunctionsVersion&gt;
    &lt;/PropertyGroup&gt;
    &lt;ItemGroup&gt;
      &lt;PackageReference Include="Microsoft.AspNetCore.App" /&gt;
      &lt;PackageReference Include="Base.Core.SharedKernel" Version="1.0.0.23885" /&gt;
      &lt;PackageReference Include="FluentValidation" Version="8.4.0" /&gt;
      &lt;PackageReference Include="FluentValidation.AspNetCore" Version="8.4.0" /&gt;
      &lt;PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="7.0.0" /&gt;
      &lt;PackageReference Include="Microsoft.Azure.WebJobs.Extensions" Version="3.0.2" /&gt;
      &lt;PackageReference Include="Microsoft.Azure.WebJobs.Extensions.DurableTask" Version="1.8.2" /&gt;
      &lt;PackageReference Include="Microsoft.Azure.WebJobs.Extensions.ServiceBus" Version="3.0.5" /&gt;
      &lt;PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.27" /&gt;
      &lt;PackageReference Include="Newtonsoft.Json" Version="11.0.2" /&gt;
    &lt;/ItemGroup&gt;
    &lt;ItemGroup&gt;
      &lt;ProjectReference Include="..\Interfaces.Avaloq.Application\Interfaces.Avaloq.Application.csproj" /&gt;
      &lt;ProjectReference Include="..\Interfaces.Avaloq.Common\Interfaces.Avaloq.Common.csproj" /&gt;
      &lt;ProjectReference Include="..\Interfaces.Avaloq.Infrastructure\Interfaces.Avaloq.Infrastructure.csproj" /&gt;
      &lt;ProjectReference Include="..\Interfaces.Avaloq.Persistence\Interfaces.Avaloq.Persistence.csproj" /&gt;
    &lt;/ItemGroup&gt;
    &lt;ItemGroup&gt;
      &lt;None Update="host.json"&gt;
        &lt;CopyToOutputDirectory&gt;PreserveNewest&lt;/CopyToOutputDirectory&gt;
      &lt;/None&gt;
      &lt;None Update="local.settings.json"&gt;
        &lt;CopyToOutputDirectory&gt;PreserveNewest&lt;/CopyToOutputDirectory&gt;
        &lt;CopyToPublishDirectory&gt;Never&lt;/CopyToPublishDirectory&gt;
      &lt;/None&gt;
    &lt;/ItemGroup&gt;
  &lt;/Project&gt;
  </code></pre>
  
  <p><strong>Problems Referencing the Nuget Package</strong>
  I can see that assemblies for the "working" package references (such as FluentValidation.dll) can be found in the global packages folder at "C:\Users\bowman_rob_a.nuget\packages". However, the global packages folder does not contain v2.2.0.0 of Microsoft.Extensions.Logging.Abstractions, it contains lots of versions but skips from 2.1.0 to 3.0.0.</p>
  
  <p>If I run from the package manager console: "install-package Microsoft.Extensions.Logging.Abstractions -Version 2.2.0" then I get the following error:</p>
  
  <blockquote>
    <p>The WriteObject and WriteError methods cannot be called from outside
    the overrides of the BeginProcessing,  ProcessRecord, and
    EndProcessing methods, and they can only be called from within the
    same thread</p>
  </blockquote>
  
  <p>Despite the error, the package does then appear in the project's packages section of solution explorer. However, it is listed with a strange path "C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.extensions.logging.abstractions\2.2.0"</p>
  
  <p><strong>Problems Referencing the Shared Package</strong>
  Because v2.2.0.0 is included in the shared package reference "Microsoft.AspNetCore.App" then I guess the assembly should be pulled from there? The assemblies for shared packages reside in "C:\Program Files\dotnet\shared." There are lots of versions of the shared package 
  "Microsoft.AspNetCore.App" but again 2.2.0.0 is skipped, from 2.1.13 to 2.2.4. However, the folder "C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App\2.2.4\Microsoft.Extensions.Logging.Abstractions.dll" does contain v2.2.0.0 of the dll. </p>
  
  <p><strong>Version Conflict</strong>
  I think the root cause of the problem could be that Azure Functions has a dependency on the nuget package chain: Microsoft.Azure.WebJobs.Extensions --> Microsoft.Azure.WebJobs --> Microsoft.Extensions.Logging.Abstractions. The latest version of Microsoft.Azure.WebJobs.Extensions is 3.0.2 and this leads down to v2.1.0 of Microsoft.Extentions.Logging.Abstractions - this is older than the v2.2.0.0 that's included in the Shared Framework Microsoft.AspNetCore.App. Does anyone know how I can change the version of a Shared Framework that's used by the compiler? I can't find a runtimeconfig.json file anywhere!</p>
  
  <p><strong>Work Around</strong>
  I have been able to make the solution build by removing the Shared Reference from all projects within the solution and adding each required nuget package individually - using the older 2.1.0 versions.</p>