19

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?

1
  • This issue has been asked before on Github Commented Dec 31, 2021 at 9:31

3 Answers 3

21
+50

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>
Sign up to request clarification or add additional context in comments.

1 Comment

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.
9

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.

3 Comments

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!
Add a framework reference instead package reference, see this answers stackoverflow.com/a/63874260/475727
@dmitry_bond follow this answer
-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>

1 Comment

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.