I'm working with an AWS Lambda project
My dev environment:
- IDE: VS Professional 2022 version 17.4.0
- Target framework: .NET 6
- Package management:
paket
This project requires packages Microsoft.Extensions.Hosting
and Serilog.AspNetCore
However, I found after adding Serilog.AspNetCore
into paket.references
, the location of Microsoft.Extensions.Hosting.dll
seems to be overridden by Serilog.AspNetCore
, causing method not found exception when creating IHost
using Microsoft.Extensions.Hosting.Host.CreateDefaultBuilder()
.
Method not found: 'Microsoft.Extensions.Hosting.IHostBuilder Microsoft.Extensions.Hosting.Host.CreateDefaultBuilder()'.
Decompiled CreateDefaultBuilder()
with JetBrains decompiler, it shows very different assembly locations are loaded between with and without Serilog.AspNetCore
:
// With Serilog.AspNetCore installed
Assembly location: C:\Program Files\dotnet\packs\Microsoft.AspNetCore.App.Ref\6.0.11\ref\net6.0\Microsoft.Extensions.Hosting.dll
// Without Serilog.AspNetCore
Assembly location: C:\Users\{user}\.nuget\packages\microsoft.extensions.hosting\6.0.0\lib\net6.0\Microsoft.Extensions.Hosting.dll
My colleague cannot reproduce this with our develop branch. I have tried clean build, manually delete folder obj
and bin
then do dotnet restore
,dotnet paket restore
, none of them works. I can reproduce this with a new created solution here
Any suggestion for me to try before I do a clean reinstall of VS and git clean -xfd
?