简体   繁体   中英

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,

在此处输入图像描述

But I can't find a NuGet package with same version 3.0.0 . How should I reference packages now? Eg 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:

在此处输入图像描述

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 ==========

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM