[SOLVED] How to multi-target a project for .NET Standard 2.0 and .NET Standard 2.1?


This Content is from Stack Overflow. Question asked by InteXX

I’m trying to multi-target a new class library to both .NET Standard 2.0 and .NET Standard 2.1, as alluded to by Karql here, so that I can use the latest version of AutoMapper (which unfortunately dropped 2.0 at the beginning of this year) in a .NET Framework 4.8 console project.

Here’s my project markup:

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


  <ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.1'">
    <PackageReference Include="AutoMapper">


All well and good so far.

But now how to reference the package’s symbols in my code? As we can see, what I have so far is fraught with compiler errors and warnings:

enter image description here

  • The Imports statement is invalid
  • The code inside the NETSTANDARD2_1 condition is disabled
  • The code inside the NETSTANDARD2_0 condition is enabled
  • All of these would seem to indicate that the project is somehow in “2.0 mode” (if that’s a thing)

I’ve reviewed this advice, but the author doesn’t describe how to actually code against the multi-targeting. In fact, all of the discussion I’m finding stops short after setting <TargetFrameworks /> in the project file.

My goal is to wrap various AutoMapper v11.0.1 functionalities with my own code, and then expose that code to my .NET Framework 4.8 project.

Am I barking up the wrong tree here? Obviously I’m doing something wrong. What is it?

Solution by Etienne de Martel

You could always try setting it by hand in your .csproj by replacing the value of the TargetFramework property with netstandard2.0:


For more tutorials visit Jtuto.com

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 4.0.

people found this article helpful. What about you?