Search code examples
.netasp.net-core.net-coreazure-functionsasp.net-core-2.1

ASP.NET Core 2.1 on full .NET Framework


Is it possible to use ASP.NET Core 2.1 and still run on the full .NET Framework 4.7.1?

I'm currently using ASP.NET Core 2.0 on .NET 4.7.1 and i'm also using Azure Functions v1 on 4.7.1 and share Class Librarys between the Functions- and the Web Projects.

Upgrading to Azure Functions v2 to go all-in on .NET Core seems a bit too risky given the current state of Azure Functions v2 so i would prefer staying on .NET Framework for now.


Solution

  • Yes.

    The metapackages Microsoft.AspNetCore.App and Microsoft.AspNetCore.All require netcoreapp, but the they are just a collection of other packages to install.

    If you install the individual packages in the metapackage, it'll work fine, just like you currently have with 2.0

    Your .csproj file will end up looking similar to this...

    <Project Sdk="Microsoft.NET.Sdk.Web">
      <PropertyGroup>
        <TargetFramework>net471</TargetFramework>
      </PropertyGroup>
      <ItemGroup>
        <Folder Include="wwwroot\" />
      </ItemGroup>
      <ItemGroup>
        <PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="2.1.1" />
        <PackageReference Include="Microsoft.AspNetCore" Version="2.1.1" />
        <PackageReference Include="Microsoft.AspNetCore.Antiforgery" Version="2.1.1" />
        <PackageReference Include="Microsoft.AspNetCore.Authentication" Version="2.1.1" />
        ...
    

    Just notice that some packages, eg. Microsoft.AspNetCore.Http.Connections are not tagged to 2.1.1, so you need to make sure you match the versions from the metapackage constraints.