This is a simple demo showing the results of getting code from full .NET to .NET Standard.
- The only project was
FullNetLibrary
, with all.cs
files - Add a new Shared Class Library project named
SharedLibrary
- Copy all
.cs
files fromFullNetLibrary
toSharedLibrary
- Delete all
.cs
files fromFullNetLibrary
- Add reference in
FullNetLibrary
toSharedLibrary
using the Shared Projects tab in the Add Reference dialog - YOU ARE NOW WHERE YOU STARTED - so you can build the
FullNetLibrary
project and have the exact same output dll as in step 1 - Add a new .NET Standard Class Library project named
NetStandardLibrary
- Add reference in
NetStandardLibrary
toSharedLibrary
using the Shared Projects tab in the Add Reference dialog - In
NetStandardLibrary
add NuGet package reference toNewtonsoft.Json
- In
NetStandardLibrary
add NuGet package reference toMicrosoft.EntityFrameworkCore
- Use the
NETSTANDARD2_0
compiler constant to add compiler directives to thePersonFactory.cs
file so it contains the original EF code for the full .NET project, and new EF Core code for the netstandard project
The result is that the FullNetLibrary
still builds the exact same code in the exact same way as before we started this exercise. And we now have a NetStandardLibrary
that builds most of the same code - the only differences being where we had to accomodate differences between full .NET and netstandard.