简体   繁体   中英

"Microsoft.Extensions.Options" version conflicts between .NET Core 3.1 Class Library and .NET Core 3.1 Azure Function V3 Class Library

I have two .NET Core 3.1 projects in Visual Studio 2019 16.4.3:

MyProject.Infrastructure (Class Library)

MyProject.Function (Azure Function V3)

The MyProject.Function project has a reference to MyProject.Infrastructure project. The MyProject.Infrastructure project has the Microsoft.AspNetCore.Identity 2.2.0 NuGet package installed.

When I compile the MyProject.Function project I get the following warning:

 warning MSB3277: Found conflicts between different versions of "Microsoft.Extensions.Options" that could not be resolved.

It looks like MyProject.Infrastructure uses version 3.1 of Microsoft.Extensions.Options because the AspNet Identity NuGet package uses Microsoft.AspNetCore.App 3.1 while MyProject.Function uses version 2.1 of Microsoft.Extensions.Options because the latest azure function NuGet Microsoft.NET.Sdk.Functions 3.0.2 uses Microsoft.AspNetCore.App 2.1.

Will Microsoft.NET.Sdk.Functions be updated soon to use Microsoft.AspNetCore.App 3.1? If not what can I do to fix the issue? Should I install the latest version of Microsoft.Extensions.Options NuGet package into the MyProject.Function project?

It seems that references in .net core using VS 2019 are a little flaky. While having this issue Microsoft released EF Core 3.1.1. I decided to update the EF Core 3.1.0 package I was referencing to EF Core 3.1.1 using nuget. When I did this I started to get all kinds of errors around missing references. At this point, I believed something was wrong locally so I checked my code into Azure Dev Ops to see if our gated build would fail or not. IT DID NOT! At this point, I deleted all the code from my local machine and got the latest from Azure Dev Ops. When I tried building it complained of a missing file "project.assets.json" and told me to do a "dotnet restore". I opened up the package manager and did just that. Once it completed without issues all my references were fixed including my version conflict with Microsoft.Extensions.Options.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM