.Net Core. general .net library project migration


#1

I have a C# project which targets on different versions of .Net Framework depending on Configuration

I have such configurations. Platform is always AnyCPU
Net40-Debug (target framework is v4.0)
Net40-Release (target framework is v4.0)
Net45-Debug (target framework is v4.5)
Net45-Release (target framework is v4.5)

My .csproj file structure like

<PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Net40-Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <!-- Other properties initialization by default values -->
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Net40-Debug|AnyCPU' ">
    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
        <!-- Other properties initialization -->
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Net40-Release|AnyCPU' ">
    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
    <!-- Other properties initialization-->
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Net45-Debug|AnyCPU'">
    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
    <!-- Other properties initialization-->
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Net45-Release|AnyCPU'">
    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
  </PropertyGroup>
<!-- other items like PropertyGroup, Compile, Import etc -->

This project file structure allows me to build the project for different frameworks by specifying certain configuration.

I wonder if it is possible to create such structure (or equivalent) in new .xproj file which let me build the project not only for .net core but also for .Net Framework v4.0 and v4.5 as I do now.

It would be great if someone showed some examples.

Regards
Alex


.NET Foundation Website | Blog | Projects | Code of Conduct