For those who are new to the party. I came across this error when creating my first plugin. Turns out I was using the wrong version of .net I was creating class library project in .net 4.6.1 and trying to use it with .net core version of Nopcommerce (Nopcommerce 4.0) I had to recreate the project using .net core and then everything worked like a charm.

P.S
During the plugin development tutorial when the author says copy this code in your .csproj file check the target frame work of sample code and change it to the latest version you are using. I checked the target frame work of other plugins and changed accordingly.