Tuesday, November 7, 2017

[.NET] Build multiple frameworks in a project

 .NET   .NET framework target


▌Introduction


We will learn how to build multiple .NET frameworks in a project


▌Environment


▋Visual Studio 2017 community



▌Implement


▋Set new configuration

In Visual Studio, go to 【Configuration Manager】 as following.




Select <New…>







▋Set target .NET framework

Open your project setting file (*.csproj in a C# class library)

Find the section

<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug-net45|AnyCPU'">
  ...
</PropertyGroup>

Which Debug-net45 is your new config name.

Add the following setting to indicate the target framework version.

<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>


▋Build

Now build and we get the different target framework in bin/



If the DLL and files ain't be built, go check the solution's property: Configuration Properties->Configuration.





▌Reference


No comments:

Post a Comment