Skip to content

Apps fail when app-local binary is lower than the version provided by a shared runtime #3252

Closed
dotnet/core-setup
#4423
@natemcmaster

Description

@natemcmaster

Steps to reproduce

Install ASP.NET Core 2.1.3 and dotnet run this project

<Project Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
    <TargetFramework>netcoreapp2.1</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.1" />
    <PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="2.1.2" />
  </ItemGroup>
</Project>
using System;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Server.Kestrel.Core;

public class Program
{
    public static void Main(string[] args)
    {
        Console.WriteLine("Kestrel assembly location = " + typeof(KestrelServerOptions).Assembly.Location);
        Console.WriteLine("Kestrel assembly version  = " + typeof(KestrelServerOptions).Assembly.GetName().ToString());
        Console.WriteLine("Deps files = " + AppContext.GetData("APP_CONTEXT_DEPS_FILES") as string);
        
        // run the kestrel server
        WebHost.CreateDefaultBuilder(args).Build().Run();
    }
}

Expected behavior

I expected the host to rollforward to the latest Microsoft.AspNetCore.App shared runtime (2.1.3), and to prefer the version of Microsoft.AspNetCore.Server.Kestrel.Core.dll it provides (AssemblyVersion=2.1.3.0) because it is higher than the app-local version (Version=2.1.2.0)

Actual behavior

The host prefers the app-local version (2.1.2.0), and when it rollsforward to the highest patch, the application fails with FileLoadException due to an assembly verison downgrade forced upon the other binaries in the Microsoft.AspNetCore.App shared runtime.

$ dotnet run
Kestrel assembly location = /Users/namc/.nuget/packages/microsoft.aspnetcore.server.kestrel.core/2.1.2/lib/netcoreapp2.1/Microsoft.AspNetCore.Server.Kestrel.Core.dll
Kestrel assembly version  = Microsoft.AspNetCore.Server.Kestrel.Core, Version=2.1.2.0, Culture=neutral, PublicKeyToken=adb9793829ddae60
Deps files = /private/tmp/lift/bin/Debug/netcoreapp2.1/lift.deps.json;/Users/namc/.dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.App.deps.json;/Users/namc/.dotnet/shared/Microsoft.NETCore.App/2.1.3/Microsoft.NETCore.App.deps.json

Unhandled Exception: System.IO.FileLoadException: Could not load file or assembly 'Microsoft.AspNetCore.Server.Kestrel.Core, Version=2.1.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
   at Microsoft.AspNetCore.WebHost.CreateDefaultBuilder(String[] args)
   at Program.Main(String[] args) in /private/tmp/lift/Program.cs:line 15

Environment data

.NET Core SDK (reflecting any global.json):
 Version:   2.1.301
 Commit:    59524873d6

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  10.14
 OS Platform: Darwin
 RID:         osx-x64
 Base Path:   /Users/namc/.dotnet/sdk/2.1.301/

Host (useful for support):
  Version: 2.2.0-preview1-26618-02
  Commit:  8b1cd0cdab

.NET Core SDKs installed:
  2.1.4 [/Users/namc/.dotnet/sdk]
  2.1.102 [/Users/namc/.dotnet/sdk]
  2.1.105 [/Users/namc/.dotnet/sdk]
  2.1.200 [/Users/namc/.dotnet/sdk]
  2.1.300 [/Users/namc/.dotnet/sdk]
  2.1.301 [/Users/namc/.dotnet/sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.0 [/Users/namc/.dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.1 [/Users/namc/.dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.2 [/Users/namc/.dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.0 [/Users/namc/.dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.1 [/Users/namc/.dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.2 [/Users/namc/.dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.3 [/Users/namc/.dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.0.0 [/Users/namc/.dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.5 [/Users/namc/.dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.6 [/Users/namc/.dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.7 [/Users/namc/.dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.0 [/Users/namc/.dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.1 [/Users/namc/.dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.2 [/Users/namc/.dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.3-servicing-26708-02 [/Users/namc/.dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.3 [/Users/namc/.dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.0-preview1-26618-02 [/Users/namc/.dotnet/shared/Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions