Failure to Install Microsoft.AspNetCore.AppRef
Asked Answered
B

3

15

When I tried installing Microsoft.AspNetCore.AppRef in my webapplication in .net core 3.1.

However, I get this error instead:

Package 'Microsoft.AspNetCore.App.Ref 3.1.3' has a package type 'DotnetPlatform' that is not supported by project 'xxxxxx'.             
NU1213 The package Microsoft.AspNetCore.App.Ref 3.1.3 has a package type DotnetPlatform that is incompatible with this project.         

Any ideas how to fix?

Bebebebeerine answered 13/9, 2020 at 15:47 Comment(1)
This issue has been asked before on GithubBaggett
S
12

According to Microsoft Learn, the correct way to reference the ASP.NET Core application assemblies from .NET Core 3.0 on is by adding a FrameworkReference, e.g.

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

  ......

  <ItemGroup>
    <FrameworkReference Include="Microsoft.AspNetCore.App" />
  </ItemGroup>

</Project>
Solorio answered 10/10, 2023 at 11:56 Comment(1)
For those unsure of how to edit your project file, right click on your solution in Visual Studio, and select "Edit Project File". You will then see the pace where you can add the FrameworkReference.Monterrey
M
8

Acording to the package description on nuget:

This package is an internal implementation of the .NET Core SDK and is not meant to be used as a normal PackageReference.

Myrmidon answered 13/9, 2020 at 18:35 Comment(3)
But how to add reference to that project then??! I need to move one some code from Asp.Net Core app into class library - HOW CAN I DO THAT if it is impossible to create class library and add to it the same packages as specified in main Asp.Net Core app?! So, test case is simple: (1) in VS 2002 create new Asp.Net Core app (it suggest to use .NET 7.0), (2) write some middlewares there, (3) try to move out these middlewares into class library... THAT LOOKS IMPOSSIBLE with VS 2002 GUI!Harmsworth
Add a framework reference instead package reference, see this answers https://mcmap.net/q/584227/-failure-to-install-microsoft-aspnetcore-apprefAtmospheric
@Harmsworth follow this answerTuck
A
-1

Just add this to your shared controller project csproj:

<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.2.2" />

Have fun.

This package deprecated because .net developers took this package into the sdk.

If you are keeping controllers in a separate project, add this to the project references for using target frameworks controllers and attributes.

<ItemGroup>
    <FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>
Alric answered 20/9, 2023 at 15:15 Comment(1)
This package is deprecated. nuget.org/packages/Microsoft.AspNetCore.Http/…Gaziantep

© 2022 - 2024 — McMap. All rights reserved.