How can I refer the netstandard2.0 in the .net472 target framework?

Jay Wang 126 Reputation points
2025-05-15T00:47:01.19+00:00

I want to build a project with target framework net472, and this project has a reference to "Microsoft.Extensions.DependencyInjection.Abstractions"

User's image

when I build the project, the output result contains the package reference with net462 dll, User's image

while I want to use the netstandard2.0 dll, so I can make the project compatible with other projects.

The main point is that I want use the netstandard2.0 dll of the reference package in the net472 target framework, how can I make it without changing the target framework of this project?

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,487 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 76,256 Reputation points Moderator
    2025-05-15T15:29:09.44+00:00

    While .netstandard 2.0 projects are compatible with both 4.7 and .net core, they may do this by multi-targeting frameworks. Generally this is done when they have conditional compile or framework dependencies.

    If a .netstandard 2.0 project is used to build a 4.7 solution, its will use 4.7 compatible target if one is defined. If used in a .net 8 solution, it will use the .netstandard 2.0 version.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.