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

Assembly Microsoft.Dynamics.Service.Plugins.dll can not be loaded. Dynamics CRM 365 Engine version 9 - CRM User creation error

Exception caught instantiating TERADATA report server extension SQL Reporting Services

Could not load file or assembly 'System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The system cannot find the file specified at Configuration class initiation in CrmServiceHelper.cv