3

I am upgrading an old ASP.NET Core 2.2 app to .NET 6

I was able to upgrade every package, however there is one that I'm missing:

Microsoft.AspNetCore.StaticFiles

This package seems to be unmaintained, in fact the last available version on NuGet is 2.2.0, which is marked as deprecated.

I checked my app's code and the only class I am using from this package is the FileExtensionContentTypeProvider class, which I use to translate file extensions to the corrisponding MIME type.

My question is: can this class be found elsewhere in a non-deprecated and up-to-date package? And if not, is there an non-deprecated equivalent that provides the same functionality (file extension to MIME type translation)?

Guru Stron
  • 102,774
  • 10
  • 95
  • 132
Master_T
  • 7,232
  • 11
  • 72
  • 144

1 Answers1

4

FileExtensionContentTypeProvider is part of the ASP.NET Core, no extra packages are required nowadays. Check out the Migrate from ASP.NET Core 2.2 to 3.0 docs. Approach to handling dependencies changed considerably during this migration and many Microsoft.AspNetCore packages are not published anymore and should not be directly referenced in the .csproj file, setting project SDK to Microsoft.NET.Sdk.Web is enough.

Guru Stron
  • 102,774
  • 10
  • 95
  • 132
  • Thanks for the info, however the project I am using this in is a library project, not a web app... are there any issues using the `Web` sdk in a simple library? – Master_T May 12 '23 at 11:49
  • 1
    @Master_T you need to add `` to the library project - see [this answer](https://stackoverflow.com/a/71321740/2501279). – Guru Stron May 12 '23 at 11:51
  • 2
    Using the FrameworkReference works, thanks! (as I suspected using the Web sdk doesn't work in a library, the project needs to have a Main). – Master_T May 12 '23 at 11:57
  • have u checkd this alternative bro @Master_T https://stackoverflow.com/questions/34131326/using-mimemapping-in-asp-net-core – user123456 May 12 '23 at 12:21
  • 1
    @user123456: thanks, but that answer suggests using FileExtensionContentTypeProvider, which is exactly what I am doing already... maybe you didn't fully understand the question. At any rate, Guru's suggestion works, so no need for further suggestions. Thanks anyawy. – Master_T May 12 '23 at 12:40
  • ok I will revise i thought it is fully alternative. – user123456 May 12 '23 at 12:42
  • `Microsoft.AspNetCore.App` package is also deprecated – Saibamen Jul 20 '23 at 06:48
  • 1
    @Saibamen package - maybe, the modern approach is to add `FrameworkReference` as written in the corresponding comment, and framework is far from being deprecated ATM. – Guru Stron Jul 20 '23 at 06:51