VisualStudio and MSBuild deciding on lower version of NuGet package than required at runtime


ASP.NET Core 2.2.0

Local Visual Studio restore + build is success.

packages folder contains :


This package is not directly referenced -- it's dependency of Serilog.

TeamCity .NET CLI build step success.

Site startup throws runtime error :

Application: TaskMonitor.exe
CoreCLR Version: 4.6.27110.4
Description: The process was terminated due to an unhandled exception.
Exception Info: System.IO.FileLoadException: Could not load file or assembly 'Microsoft.Extensions.Options.ConfigurationExtensions, Version=, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
   at Microsoft.Extensions.Logging.LoggingBuilderExtensions.AddConfiguration(ILoggingBuilder builder, IConfiguration configuration)
   at Microsoft.AspNetCore.WebHost.<>c.<CreateDefaultBuilder>b__8_2(WebHostBuilderContext hostingContext, ILoggingBuilder logging)
   at Microsoft.Extensions.DependencyInjection.LoggingServiceCollectionExtensions.AddLogging(IServiceCollection services, Action`1 configure)
   at Microsoft.AspNetCore.Hosting.WebHostBuilderExtensions.<>c__DisplayClass7_0.<ConfigureLogging>b__0(WebHostBuilderContext context, IServiceCollection collection)
   at Microsoft.AspNetCore.Hosting.WebHostBuilder.BuildCommonServices(AggregateException& hostingStartupErrors)
   at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build()
   at TaskMonitor.Program.Main(String[] args) in D:\TeamCity\buildAgent\work\e9ff385151b10e4c\Services\TaskMonitor\TaskMonitor\Program.cs:line 20

So something wants 2.2.0.

Since Serilog is happy with version > 2.0.0 I added explicit reference to 2.2.0 to .csproj :

<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="2.2.0" />

But local Visual Studio build still decides on version 2.0.2 as does TeamCity and so app fails to startup with same error.

asked on Stack Overflow Jan 29, 2020 by BaltoStar

0 Answers

Nobody has answered this question yet.

User contributions licensed under CC BY-SA 3.0