Use Multiple Framework in your single Visual Studio project - Multi Framework Targeting

If you want to build your code with couple environments compliance, Visual Studio allows us to generate for multiple architecture.

Visual Studio can generate libraries for .NET Framework 4.6.2 while building libraries for .NET Standard 2.0.

One compile, couple outputs :)

In order to convert your Visual Project, Open .csproj file that you want to use multiple framework than manipulate TargetFramework tag.


For Example;
I created a Project for .NET Standard 2.0 from Visual Studio as usual then set it for already .NET Framework 4.6.2

Visual Studio creates .csproj file as following ;

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

  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
    <Authors>United Response SAM Team</Authors>
    <Company>United Response</Company>
    <Description>United Response SAM Team</Description>
    <Version>1.0.0.2</Version>
  </PropertyGroup>

</Project>

change following and add other target framework;

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

  <PropertyGroup>
    <TargetFrameworks>net462;netstandard2.0</TargetFrameworks>
    <Authors>United Response SAM Team</Authors>
    <Company>United Response</Company>
    <Description>United Response SAM Team</Description>
    <Version>1.0.0.2</Version>
  </PropertyGroup>

</Project>

once you save and open project in Visual Studio and rebuild the project, Visual Studio is going to generate proper libraries under bin-> Debug (or Release -based on your current configuration-)

Screenshot of Debug directory;





enjoy....






Comments

Popular posts from this blog

Complex Query in QueryExpression in Microsoft CRM 2011

Exception caught instantiating TERADATA report server extension SQL Reporting Services

Microsoft Power Apps Portal integration with Dynamics 365 CE On-Premise - Step By Step Guide