Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET Core 3: How to reference 3.0.0 assemblies in custom libraries?

I see that applications that reference the Microsoft.AspNetCore.App framework (AKA ASP.NET Core 3.0) uses types from the assembly Microsoft.AspNetCore.Mvc.Abstractions, Version=3.0.0.0,

enter image description here

But I can't find a NuGet package with same version 3.0.0. How should I reference packages now? E.g. if I want to override ControlBase, how should I reference the Microsoft.AspNetCore.Mvc.Core, Version=3.0.0.0 assembly if there are no such package versions on NuGet?

After adding the following:

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

I have another kind of waning:

enter image description here

Which gives the error:

NETSDK1073: The FrameworkReference 'Microsoft.AspNetCore.App' was not recognized Routines.AspNetCore C:\Program Files\dotnet\sdk\3.0.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targets 263

Unloading and reloading the application doesn't help.

The same problem occurs in an empty new project:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netstandard2.1</TargetFramework>
  </PropertyGroup>

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

Compilation

1>------ Rebuild All started: Project: ClassLibrary1, Configuration: Debug Any CPU ------

1>C:\Program Files\dotnet\sdk\3.0.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(263,5): error NETSDK1073: The FrameworkReference 'Microsoft.AspNetCore.App' was not recognized 1>Done building project "ClassLibrary1.csproj" -- FAILED. ========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

like image 614
Roman Pokrovskij Avatar asked Sep 30 '19 21:09

Roman Pokrovskij


1 Answers

You need to add a FrameworkReference to your csproj

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

See Migrate from ASP.NET Core 2.2 to 3.0 for more details

like image 61
ESG Avatar answered Nov 09 '22 13:11

ESG