twitchax / AspNetCore.Proxy

ASP.NET Core Proxies made easy.
MIT License
525 stars 83 forks source link

Issue with targeted libraries in .csproj file - .NET Core 3.1 targeted but refs to old 2.2 libraries #40

Closed davesofthunder closed 4 years ago

davesofthunder commented 4 years ago

I have a .NET Core 3.1 project that has a reference to AspNetCore.Proxy version 4.0.1.

I am getting console warnings stating the following:

Severity Code Description Project File Line Suppression State Warning AD0001 Analyzer 'Microsoft.AspNetCore.Mvc.Analyzers.TopLevelParameterNameAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'. MyProject C:\source\MyProject\CSC 1 Active

This is happening I believe because the AspNetCore.Proxy project targets the .NET Core 3.1 framework but references obsolete packages targeting 2.2.

Here is the relevant block of the AspNetCore.Proxy.csproj file:

`

<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="2.2.0" />

`

The same problem is documented here: https://github.com/aspnet/websdk/issues/1203

As shown here in the migration guide from .NET Core 2.2 to 3, I think those references should be removed.

https://docs.microsoft.com/en-us/aspnet/core/migration/22-to-30?view=aspnetcore-3.1&tabs=visual-studio#update-the-project-file

Thanks!

twitchax commented 4 years ago

I actually filed an issue with Microsoft about this.

https://github.com/dotnet/aspnetcore/issues/14723

I don't mind making fixes, but I am not sure removing those references will address the issue. Those references are for when not building netcoreapp3.1. The only 3.1 references I have are.

<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
  <FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>

Which should be fine. Right? Am I missing something? :P

twitchax commented 4 years ago

@davesofthunder, does that make sense?

daveyjay commented 4 years ago

Thanks for explaining that and the link - sorry my bad! I didn't realize that code was conditional (my bad eyes missed the !=. I can see that the correct framework is targeted.

Just trying to figure out where my project has a nested dependency on 2.2 and can't seem to find any other reference to .net 2.

I will continue investigating - going to try one of the suggestions in that link about installing fxcop.

twitchax commented 4 years ago

Ok: cool!

Yeah, I definitely saw this for a while, which is why I filed the issue originally.

twitchax commented 4 years ago

@davesofthunder, what happens when you remove this library? Does removing it temporarily change anything?

daveyjay commented 4 years ago

I figured out the problem - was nothing to do with this at all - one of my .net core 3 class libraries that was referenced had a reference to Microsoft.AspNetCore.MVC Version 2.2.0 in there - my bad!

twitchax commented 4 years ago

No problem: good to know!