VS2022 makes class libraries with wrong .net framework version

I just tried making a C#9 class library with VS2022 and get the following error when adding it to my project:

When I make the class library with VS2019, this does not happen and it works as expected.

Something does not seem right with the core library when creating a new class library either, I find I have to delete the nuget package and reinstall it for new projects to build correctly.

This is on the latest visual studio extension version.

Can you please show step by step. We just try quickly and not see any problem.

if project was created from extension 2.1.801 or earlier then yes, it could be happened, even opened in 2.1.802 because template config still in 2.1.801.

Of you added a C# class library instead of TinyCLR class then the full .net gets pulled in and the whole project gets messed up

Yes, this project is some months old.

I just double checked and it was a tinyclr project.

You also have to ensure when adding the .cs file that TinyCLR is also selected when adding to a TinyCLR project. As Gus mentioned if you inadvertently add a regular C# class file it will gum up the whole works.

1 Like