ipjohnson / Grace.DependencyInjection.Extensions

Grace Extensions for ASP.Net Core
19 stars 7 forks source link

Switch Grace.AspNetCore.MVC to use TFM netcoreapp3.0 #24

Closed silkfire closed 3 years ago

silkfire commented 4 years ago

The Grace.AspNetCore.MVC project currently makes use of outdated ASP.NET Core dependencies, previously distributed as NuGet packages. Since .NET Core 3.0, ASP.Net Core packages are included implicitly in the SDK by adding a framework reference to the project file.

I suggest to change the project from targeting .NET Standard to targeting .NET Core to support the newer packages. Any .NET web project surely wouldn't target Xamarin.iOS or other framework so this should be a safe operation in my opinion. The tricky part is determining whether to use .NET Core 3.0 or 3.1.

As an example, my project does not use Newtonsoft JSON, yet because Grace.AspNetCore.MVC uses the old NuGet packages (ASP.NET Core 3.0+ is part of the SDK, no longer distributed through NuGet), the Newtonsoft.Json.dll ends up in the artifacts of my deployed application.

image

The project TFM (Target Framework Moniker) should be changed to netcoreapp3.0 or netcoreapp3.1:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netcoreapp3.0</TargetFramework>
  </PropertyGroup>

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

References

https://andrewlock.net/converting-a-netstandard-2-library-to-netcore-3/ https://stackoverflow.com/a/57760357/633098

ipjohnson commented 4 years ago

I actually need it on asp.net core 2.1 currently. That said it makes sense to support a build target of 3.0 in addition to 2.1

I'll look at adding it with some conditional package references

silkfire commented 4 years ago

Could we push this now as .NET 5.0 has been released?

ipjohnson commented 4 years ago

Touche .... let me look at it this evening. Sorry about that.