Reputation: 5379
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
Upvotes: 3
Views: 207
Reputation: 46621
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:
Upvotes: 3