DOTNET 6 and Visual Studio 2022
Currently I am only working with LTS version of .NET, it’s rare that there is any benefit for me from updating to non LTS versions. As .NET 6 has just been released I’ve downloaded it and at the same time downloaded the brand new Visual Studio 2022.
Visual Studio installation
I was very impressed with the VS 2022 installation, for a fairly large install it downloaded pretty quickly. When the install was completed, it didn’t insist on a reboot, though it was recommended. This is nice as it lets you have a look around straight away.
You can’t help but notice the new icons. MS have made quite a big thing about this but it’s something they do on each release. I guess they are a bit cleaner than the old ones and I will eventually get used to them. Overall I quite like the new look, for the dark theme at least. There are/will be more themes available but previewing them isn’t a great experience as all you seem to get is a tiny image that frankly doesn’t tell you much.
Another nice feature was that all my settings seem to have been retained. I can’t recall off hand if this has happened previously but it is certainly a nice to have. Personally I still take a look through a lot of the settings to see if there is anything I want to change.
I opened a solution with a view to upgrading it to .NET 6. This went well and all seemed to work as normal. One thing I did notice was that the project properties page has changed to one that scrolls rather than separate pages. Personally I’m not very keen on this but in .NET core I use it less anyway than I would in .NET framework.
Updating Paket files
As I use Paket I wanted to allow the .net6.0 framework to be used. All my attempts to update the paket dependencies file failed. It turns out that the correct way to add .NET 6 is to use dotnet6
// limit frameworks to LTS versionsframework: dotnet6, netcoreapp3.1
NOTE that you can’t use dotnet6 in the TFM, instead you use net6.0 Unfortunately this didn’t resolve the whole problem, as I use global.json to specify which SDK to use I needed to update that too but that’s where I started to come unstuck. Eventually I gave up for now, I’ll return to it in a week or two when hopefully the issue will be resolved. The issue seems to be related to the TFM
So for now I have global.json set to use .net 6.0.100 and everything else is unchanged and that seems to be working, which is a start.
First impressions are promising. Visual Studio looks nice. As always there are some extensions that haven’t been upgraded yet. If they aren’t done over the next few weeks I’ll look harder at whether I need them. The main one is Resharper, when that is up and running I’ll look at using VS 2022 full time.
I ended up having so many issues with my upgrade attempts that I gave up for a while. It’s now a couple of weeks on from my first attempt and I have decided to have another go.
There is a new version of Paket which will likely resolve the issues I was having. The paket developers are notoriously quick at resolving these sorts of issues. The version I am using now is 6.2.1.
After going up a few blind alleys I now have a process for adding .net 6.0 to my existing libraries. Put simply this is a copy and paste exercise.
In my case I create a new branch in my repo and do it there. The first thing is to remove all the things that aren’t code e.g. the .paket folder and the sln and proj files along with anything else that can easily be regenerated or might specify or depend on a specific version of .Net.
The next step is to recreate the sln and proj files using the dotnet new command. I then open the new solution in VS 2022 and add any project references etc. The next step is to put the TFM’s in place as normal and to turn off ImplicitUsings. I then ensure the appropriate nuget packages are installed. The library should now look pretty much like normal. At this point I install paket as usual and run
I then update the paket dependencies to what I need it to be and I’m pretty much ready to go. So far this has worked consistently for me.