Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I change a .NET standard library to a .NET framework library?

I'm writing a class library for a simple parser in C#. When I first created it, I used .NET standard 2.0, but now I need to migrate it to .NET 4.6 both to conform to the other projects in my solution and in order to use NUnit.

I tried to follow the instructions in the Microsoft documentation, but when I try to select another framework in the properties, I can only find other .NET standard versions.

How can I migrate it? Will I need to manually edit the .csproj file?

like image 881
Edward Minnix Avatar asked Jul 05 '18 14:07

Edward Minnix


People also ask

Can I use .NET standard library in .NET Framework?

NET Standard 2.0. . NET Standard 2.0 is supported by all modern platforms and is the recommended way to support multiple platforms with one target.

How do I change .NET standards?

In Visual Studio select Analyze and then Portability Analyzer Settings. In the General Settings window, select . NET Standard 2.0 under Target Platforms, and then choose OK.


2 Answers

Open up the project file (.csproj) and change the TargetFramework to net462

<PropertyGroup>   <TargetFramework>net462</TargetFramework> </PropertyGroup> 
like image 73
Jammer Avatar answered Sep 23 '22 07:09

Jammer


My personal experience in Visual Studio 2017 is that recreating project and adding existent sources is the simplest, safest and most effective way - because .Net Framework based csproj file has extra xml elements (comparing with Standard based), it seems changing "TargetFramework" is not enough. Below is portion of diffs appeared by default:


enter image description here

like image 31
Vlad Novakovsky Avatar answered Sep 21 '22 07:09

Vlad Novakovsky