Installing Visual Studio 2022
If you're a .NET developer, there is no other tool more powerful than Visual Studio's IDE. Today, with the new release of VS 2022 from Monday, I review my experience of installing VS 2022.
After watching the launch of Visual Studio 2022 on Monday (Nov. 8th), I was quite impressed with everything included in this release (awesome thanks to the ASP.NET team for such a great product!)
Before the launch, I was using a Preview release of Visual Studio for a while.
So, needless to say, I was excited about downloading it and putting it to good use.
Once I downloaded and ran the installer, I proceeded to immediately crack open the box and see what VS 2022 had in store for modern developers.
Installation
Compared to the old days where installations occurred using CDs, Visual Studio 2022 installed relatively quick.
The installation process took about ~15 minutes. Of course, since I was using a Preview version of .NET 6.0, I noticed it took the liberty of uninstalling the preview version of .NET 6.0.
I didn't think of anything at the time, but continued to move on to the next and most important factor: performance.
Performance
Next to security, I feel performance is always the number one factor developers should focus their attention when writing code.
The Visual Studio Team definitely focused their efforts on performance because Visual Studio 2022 appeared rather promptly when I double-clicked.
I'm guessing this is because of two things: Visual Studio 2022 now being 64-bit and .NET 6.0 running as fast a possible with great strides in performance under the hood.
After receiving the splash screen, it took ~10 seconds before it disappeared and displayed the real estate containing the common IDE panels.
Once I had the IDE fully loaded, I had to attend to something else and I closed it down.
Problem 1: Loading Projects
Ok, ok, ok...I need to disclose something.
Before I go into this next section, I want to say I didn't get enough sleep the night before and wasn't thinking straight.
I had a solution containing 16 projects. When I attempted to load the solution in VS 2022, it loaded fine, but gave me some errors about a path issue.
Hmm...strange.
I checked the tweets and found one thanks to NDepend (which is one of the best tools on the market for .NET devs)! While this was a good suggestion, it still didn't fix the issue (I added it anyways because it couldn't hurt to add it, right?)
At that point, I got a little scared and wanted to see if everything was ok. So I went back to VS 2019 to reload my project.
My projects didn't load at all except for one: the Database Project. All other 15 projects failed to load.
Visual Studio 2019 couldn't find the .NET version. I thought .NET 6.0 was included with Visual Studio 2022.
It was already installed, but I proceeded to download both the SDK and Runtime of .NET 6.0 and install both.
Still didn't work.
After thinking about this, it hit me.
Solution 1 - Get enough sleep!
Ok, we already knew that solution, but to fix the problem of my solution not loading, I figured out...
Solution 2 - To use the next version of .NET, I needed the x86 version of .NET 6.0 for VS 2019. Since VS 2022 is now 64-bit, I needed the x64-bit version of .NET 6.0. I only downloaded the x64 version of .NET 6.0.
Once I loaded .NET 6.0 x86 version, my solution loaded into VS 2019 successfully.
Remember, the installer removed the Preview version of 6.0-preview-x.
Problem 2: Updating Old Projects - Where did you come from?
When I tried to load my ASP.NET Core 5 project into VS 2022 and run it, the solution wouldn't run saying there was an issue with the app.UseEndpoints()
.
This code seems to be "old" compared to what I discovered in the new web app projects.
For those who understand ASP.NET Core and followed the conversation about minimal APIs (back in August), this won't be much of a surprise to you.
But this caught me completely off-guard.
I thought I could transition my projects easily over to .NET 6.0. Unfortunately, it'll require a bit more work.
Solution 1 - I opened VS 2022 and clicked "New ASP.NET Core Web App" to see what was different from my existing project by examining a new Program.cs
file.
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddRazorPages();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error");
// The default HSTS value is 30 days.
// You may want to change this for production
// scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthorization();
app.MapRazorPages();
app.Run();
So that's it!
This is the Program.cs
file. That's our new "startup" for web applications.
Looks a little sparse, right? No ConfigureServices()
or Configure()
method. And there wasn't even a Startup.cs
.
I remember the .NET team chatting at times about creating a minimal API and pushing the boundaries, but I thought it was meant only for APIs. I didn't think this went across entire web apps.
They basically took the Startup.cs
and moved everything into the Program.cs
without the top-level spaces or file-scoped namespaces.
Interesting.
Conclusion
As you can see, there were some surprises for me (along with the awesome "hot reload" feature) and the familiar IDE.
The subtle changes requires some new setup for older applications (>1 year) if you are thinking about transitioning your codebase into ASP.NET Core 6.
As I update some of my projects, I'll be posting the progress along with some tips and tricks.
Did you find an awesome feature in VS 2022? Did something go wrong? Post your comments below and let's discuss.