I ran into an interesting problem today when upgrading a visual studio 2008 project to visual studio 2012, whilst trying to leave the targeted framework to .NET 3.5. Each time I tried to open the solution all my test projects automatically upgraded to .NET 4.0 regardless of what I did. It was impossible to downgrade the project using either the project property page or manually editing the project file. I’d make the change and then reload the project, a project conversion report would be shown and the project was back to targeting 4.0 again.
After a little more digging around I noticed that it was only my test projects that were doing this, all the other class libraries, etc. were perfectly happy targeting 3.5. After a little more experimentation I isolated this to the project type guids section, if I removed this from the project definition then I could re-target my unit test project at v3.5 and everything was happy. Note: As the linked blog post indicates, you might lose the ability to add new tests directly from the “Add New” menu, but it would appear you can either have one or the other, but not both!
As part of his fantastic ‘What is .NET standard‘ presentation at DDD12, Adam Ralph provided an amazing amount of detail in such a short amount of time. One of the most valuable points, which is completely obvious when you think about it, is how you should work with .NET standard when creating libraries. NET standard now comes in a multitude of flavours: currently 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6 and 2.0. When starting out . . .
If you’re trying to access a class library (.NET Standard) from a traditional console application (in VS2017 those can be found under ‘Windows Classic Desktop’) you will run into problems; which can feel a little strange for something that was pretty simple in VS2015 and earlier. You can add a reference to the class library project (Resharper will even volunteer to add the dependency / namespace reference if you don’t already have it). But the . . .