How can I install the NuGet package Microsoft.AspNetCore.App.Ref?

KevY 30 Reputation points
2023-07-09T21:04:11.48+00:00

I need to use the Microsoft.AspNetCore.Mvc.ModelMetadataTypeAttribute in my application. I am able to use it with the NuGet package Microsoft.AspNetCore.Mvc.Core. However, this package has been deprecated. I tried to find a replacement for this package. I found that it's in the Microsoft.AspNetCore.App.Ref in .net 7 ModelMetadataTypeAttribute Class. But when I tried to install this package, I got this error "NU1213 The package Microsoft.AspNetCore.App.Ref 7.0.8 has a package type DotnetPlatform that is incompatible with this project."

I am wondering if there is an alternative for me to use Microsoft.AspNetCore.Mvc.ModelMetadataTypeAttribute in .net 7.

Thanks!

Developer technologies ASP.NET ASP.NET Core
0 comments No comments
{count} votes

Accepted answer
  1. Anonymous
    2023-07-10T02:25:05.82+00:00

    Hi,@Kevin Yip

    Please check this document:

    With the release of .NET Core 3.0, many ASP.NET Core assemblies are no longer published to NuGet as packages. Instead, the assemblies are included in the Microsoft.AspNetCore.App shared framework, which is installed with the .NET Core SDK and runtime installers.

    You could try as below:

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

    If the answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best Regards,

    Ruikai Feng

    17 people found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Akmal Nodirov 10 Reputation points
    2023-08-29T02:21:56.0866667+00:00

    It works for me too. At first, I thought I needed to install the package, but just including the framework reference tag was enough.

    2 people found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.