Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is Microsoft AspNetCore App showing twice in Dependencies

Tags:

asp.net-core

Creat a new .net core web api project

View Dependencies

See picture below.

Why is Microsoft.AspNetCore.App required twice? It is in the default csproj:

 <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.App" />
    <PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
    <PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.0.2105168" />
  </ItemGroup>

And also under SDK.

I don't understand the reason for this, very confusing. If I remove it from csproj and do a clean and run, application runs

enter image description here

like image 977
Noel Avatar asked Nov 17 '25 16:11

Noel


1 Answers

That's because Microsoft.AspNetCore.App is both a dependency of your application (the NuGet node) as well as a dependency of the SDK you're using. You can find the SDK at the top of your project file:

<Project Sdk="Microsoft.NET.Sdk.Web">

The Web SDK references the Microsoft.AspNetCore.App package in one of its MSBuild target files. You can find the SDK targets in the SDK installation folder: C:\Program Files\dotnet\sdk\<version>\Sdks\Microsoft.NET.Sdk.Web\Sdk

Starting from .NET Core 3.0, these references will change and you can reference the framework using a <FrameworkReference> element rather than a <PackageReference> element to avoid ambiguity. See the following GitHub issues for more info:

  • https://github.com/aspnet/Announcements/issues/325
  • https://github.com/aspnet/AspNetCore/issues/3612
like image 128
Henk Mollema Avatar answered Nov 20 '25 13:11

Henk Mollema



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!