Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Microsoft.AspNetCore.Mvc.Core marked as deprecated and causing publishing errors in a NET 7 web app

I have a web app started in .Net Core 3.1 and upgraded to NET 7 almost year ago. I use the mentioned package because I use the below routing strategy:

enter image description here

I need areas and subareas in my routings to a better organization. So, for have subareas working I had to build a custom RouteValueAttribute:

enter image description here

This was working fine in .net core 3.1, NET 5 and even in NET 7 for some time, however when I tried to publish the web app, I started facing problems due to libraries deprecation, such as:

enter image description here

SicotX.Business.Shared is a dependency of my project, and this dependency, also, depends on SicotX.Global, which is the place where SubAreaAttribute resides. To use these classes, RouteValueAttribute class and AttributeUsage Attribute I have to add the beforementioned package.

I'm not been able to publish, also, there's none info about the new package or relocation Microsoft will put those ones, just marked as deprecated and that's it.

Any idea about this? There's any idea on how to tackle the area management for routes by using a different strategy?

Thanks

like image 636
Aldemar Cuartas Carvajal Avatar asked Nov 26 '25 17:11

Aldemar Cuartas Carvajal


1 Answers

For those running into this error, I did the following.

  1. I removed the references to the deprecated nuget packages.
  2. I added the following to my csproj file. (Right click the project and select 'Edit Project File')
  3. Rebuild your project.

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

To confirm I got what I wanted, I went into the definition for the keyword Route which was previously redlined, and then I saw the following at the top of the file, which made me comfortable. Also, there may be issues with Blazor apps, but I was upgrading an old API class library project so this worked for me.

#region Assembly Microsoft.AspNetCore.Mvc.Core, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60 // C:\Program Files\dotnet\packs\Microsoft.AspNetCore.App.Ref\8.0.3\ref\net8.0\Microsoft.AspNetCore.Mvc.Core.dll #endregion

like image 69
Bill Avatar answered Nov 28 '25 16:11

Bill