Okay.
In this lesson, we're going to take a look at adding some extensions into VSCode to make it function
more like an integrated developer environment, such as the full blown version of Visual Studio.
This is something we need to do with VSCode.
It's a very popular, very good code editor, and by adding extensions, we can make it function more
like the tools that possibly you're more comfortable with.
Now, using VSCode is not a requirement for this course.
It's what I'm going to demonstrate on because VSCode is well, first of all, it's excellent.
Second reason it's free.
Third reason it's cross-platform.
So it's the same experience whether you're using Mac, Windows or Linux.
And it's also just about the most well, it is the most popular code editor out there.
Over 70% of developers use this on a regular basis.
So it is a good tool to use, and it's a good tool for me to demonstrate on.
And that's what I'm going to do.
But we do need to add some extensions to this.
Now we get these pop ups telling us that VSCode is recognized that we've got a C-sharp code file open
or I have in my case, and it's saying, hey, do you want to install the C-sharp extension or the C-sharp
dev kit?
We will do, but I'm just going to go through and show you what I currently have and how my VS code
is currently set up, so you can do the same if you wish to.
Now, first of all, let's close this down and we'll go to code and we'll go to settings and click settings.
And then if we just click this button here, this will take us to the JSON file of the settings that
have changed from the defaults.
Now inside here there's hardly anything that's changed apart from the font sizes.
In my version of VSCode it's like a new installation.
And there's one more thing that I have enabled, which is autosave.
I would actually recommend you do turn this on, and if you click on the file menu, then there's an
option to enable autosave.
And what this will do as it says on the tin.
Really, it's going to save your files automatically.
And in order for the compiler to pick up any code changes you've made, then the file does need to be
saved, so I do recommend turning that one on as well.
But let's take a look at the extensions that we need.
Because at the moment all this is is a colorful text editor.
We have text that's colored kind of nicely, but we don't get any help.
If I hover over any of these things, I don't get any help at all, which I would normally expect to
see in a code editor or an IDE.
So we're going to make some improvements, and let's go to the extensions tab in VSCode.
And I do not have any extensions installed at the moment.
But let's start off by looking for C sharp and see what options are available for C sharp.
Now what we need and what we wish to install is the C sharp dev Kit.
This is what we use nowadays for developing C sharp in VSCode, and it gives us a number of features
to help us manage our projects.
Now, if you are used to using Visual Studio and this is new, we've got to get started with C Sharp
Dev Kit.
I've not seen this before and I think I'm just going to ignore it.
We don't need to be signed in to VSCode to use this.
And I want to say I'm just going to close it.
I don't want this welcome window, nor do I need it.
So we've got this installed.
Now, if we go back to one of the code files and I go back to what I was looking at, the weather forecast,
we can see that we've got some references.
Where has this been used in other places.
So we can click on this and we can get a view of where this, this code or this property has been used
elsewhere in our code base.
We can also hover over things and we can get some documentation about what is being used and where it's
being used.
And all of this stuff is pretty useful, so we definitely need that to help us write C-sharp code.
Another thing that we'll be using early on in this course is we're going to make use of SQLite as our
database server.
Now we're not going to use SQLite for production, so please don't worry about that.
But we are going to use SQLite early on because this is a very quick, easy way of getting a database
up and running, and so that we can see the contents of that database.
We're also going to install this thing called SQLite viewer, which will allow us to click on the database
file and see what is in the database.
Because SQLite just uses a file as a database rather than storage like a SQL server would.
So we'll go ahead and install this one as well also, so that the let's see the icons are a bit better.
Then I'm also going to install a material icon theme by the way.
One another thing that we got with the C-sharp dev kit is this Solution Explorer.
And this gives us a visual studio like view of our different files and folders inside our project.
So we can see the solution file and what's contained in it by clicking on that.
If we look at the API or click on the API folder, this will give us a view of the project file.
We'll come back to this stuff a bit later, but we've got a Visual Studio like Solution Explorer that
came with the C-sharp dev kit as well.
Now back to extensions.
I'm just going to install also a material icon theme, and this one here is what I'm looking for.
It doesn't do anything functional, it just makes the icons look a bit better in my opinion.
So I'm going to install that.
And then I'm going to set the material icon theme.
And if I go back to the explorer view, we can see that the icons full of files and folders have changed
slightly in my opinion.
They look a bit better.
And another thing that we need to install as well, particularly for DotNet, is we're going to install
the NuGet gallery.
And this is just a quicker and easier way that we can add packages to our project that help us develop
what we're building here.
So we're also going to install this NuGet gallery and add this to our project.
And there we go.
Now we've got those extensions installed and available.
We won't use them all straight away, but these are what we need for.
Net and reserve the right to come back and add more as we need to.
But this should be enough to get us started.
1 or 2 other things I'll just point out very briefly if I go to the background of VS code, I've got
this option to show all commands, and the shortcut keys for that is shift command P.
In my case, obviously from windows you'd have a slightly different keyboard shortcut combination.
So please do take a look at that.
If we press that keyboard combination then we get a bunch of different options in here.
Now if VSCode ever doesn't play nicely and it doesn't feel like it's doing what it should be doing,
or it gets stuck, or any myriad of things that could go wrong that do go wrong sometimes, then your
first troubleshooting step is just to look for developer and reload window.
This won't restart anything.
If you've got your API server running, it will keep that API server running, but it will just give
VSCode the kick that sometimes it needs and do make a habit of doing that as your first troubleshooting
step.
Another thing that I demonstrated was opening up VSCode from the terminal by using code, followed by
a space, followed by a period.
If you didn't get that behavior and you needed to open up VSCode and then open up your project folder,
then again, if we go to show all commands, then just search for path and you might want to use this
command shell command install code command in path.
And that will add this to your environment path variables.
So that when you're in something like your command prompt or PowerShell or your terminal, then it will
recognize code as a valid command effectively.
And then you can open the current folder by using code space period.
So please do that if you need to.
Another thing that I like to do that I do often in VSCode is use this keyboard shortcut.
Go to file.
And this has numerous advantages.
It's faster than navigating the file and folder view.
Typically, to get to a class you want to open, and also it means you don't need to have that open
all the time.
You could just use go to file.
And supposing I wanted to open up the weather forecast controller, then I could just start typing the
start of the name of the thing I'm looking for, and then simply open it up directly in the editor without
needing to expand this.
And it gives me more room for the code, and I don't need to keep the solution explorer open.
So I do prefer to use that command as well.
So that's VSCode.
Like I say, you don't have to use it, but that's what I will be demonstrating everything on.
You do have alternative options.
Visual studio continues to be great for windows, but it's not available on Mac or Linux.
And also the JetBrains products are also excellent, but they do require a subscription.
And like I said, I'm going to stick with VSCode.
So now we have this.
Let's take a look next at what we got when we created our API project.
And we'll take a look at that next.