5 reasons to choose VS Code for .NET development

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
many people have asked me the same question why do you use BS code for all your YouTube tutorials instead of just using visual studio it's a fair question and after answering it over and over again today I want to present you the top 5 reasons why I prefer vs code for net development let's start let's start with the installation experience because this is one of those things that everybody has to go through and experience itself is going to be very different between visual studio and visual studio code but before going there let me actually establish kind of a baseline of what kind of machine we're going to be using for the installation so let me just show you the specs of my box very quickly uh over here here's my task manager and what you're going to see is that I am using an Intel Core i7 CPU of the I guess it's the 9th generation and so which is a very fast CPU it works great for me so that's going to be the CPU in terms of memory what I'm using here is 32 gigabytes of memory which is plenty of memory is more than what I usually need and in terms of disk I'm going to be choosing here's my OS disk and you can see what I'm using is a Samsung SSC 970 Evo plus 250 gigabytes that's going to do with my teeth so by all means this is a very very fast machine it could be faster but is is fairly fast and so this is what we're going to be using for all the installation that you're going to be seeing right let me minimize This and like I said I have both installers here we're going to get started with bezel studio so I'm going to click on the episode to installer here double click there and I am presented with this screen which is the installer for the installer so you have to install installer first so I'm going to click on continue and so it's going to use download a few bits and so this is going to become the actual application that's going to be in charge of install visual studio so let's just give it a second and here we are now in the uh installation experience for visual studio now before we select anything on this screen one thing I should clarify is that all I want to get into my box is a tooling required to develop.net and infinite code applications and of course with c-sharp right that's all that I need in my box so this is not about either desktop development or python development or game development or any other kind of development this is just about getting a tools for that aspinal cord and C sharp okay and so one thing to notice here already before even selecting anything is um how much space is going to take because if you look at this corner down here notice that even before installing anything these are really going to take 1.13 gigabytes of my box this is just obvious to record experience and you're going to see that number changing as I select components over there now the expectation in this screen is that you select what is going to be the workload that you want to install and the workload is just the bundle of the different set of two links that are going to be installed in your box for the type of application that you want to develop right so as you can see that there's many types of applications that you're going to be able to develop with visual studio and that's expected and but uh as a unit developer it can be challenging to know right what exactly I'm supposed to install here right and even I I get a little bit confused in terms of what to select here anytime I'm going to develop my applications and you can see that there's even a prompt on the top here saying hey you need help choosing what install right so this is we know that this is a bit confusing so that's one of the things that I don't really like about this this experience here uh because I I believe these things should be very straightforward for a.net developer I should not need to even choose here and get confused about what we saw now from experience I do know that what I want here is the infinite and web development workload Heroes I'm going to actually select that one okay and notice that just by selecting that my this space has pumped from one gigabyte to about like a little bit more than nine gigabytes right so that's already a bit shocking in for me how much space is it going to take it is a lot of space but things that and not just that there's a this installation is just by choosing that this is going to involve a lot of components that I'm pretty sure I'm never going to be using right and things that actually don't make sense for me for instance if you see on the right side over here notice this set of optional components that have been pre-selected for me uh as part of this installation now the thing is that I mean I'm going to be doing.net development specifically a one of the latest version of versions of.net and that it has nothing to do with the Net Framework right so why would I want to install data frame for a development tools so I'm going to just unselect that and again also the framework Pro and item templates right so that's not needed I also don't need a cloud tool for web development uh the network filing tools uh maybe so let's let's keep that Entity framework tools I'm not going to be doing any sort of Entity framework development in my case uh so I don't need any framework a light share sure that could be useful uh the net evolving with WSL not really I'm not going to be debugging in WSL into the code that could be also useful so let's keep that um so yeah space went down to 7.5 to 55 gigabytes but still if we now go into individual components I like to be very very picky about this because when you install when you install one tool like this and you know that there are going to be a bunch of modifications to your box right a bunch of things get installed and that over time because result in um different kinds of problems depending on what you start right so just install the minimum that you're actually going to need and so in these individual components screen uh notice that this is already prompted me to install both the net 6 runtime and the Net 7 runtime right uh but in my case I only want to do the net A7 development so why would I want done in six so I'm going to remove the net six but notice this I actually can't remove the Netflix because it is saying that it is required for the workload that I have selected right so and that that I don't really like like if I'm going to be doing that in 7 development why would I want to have done it also the net six runtime installed here so um so on click cancel because I do need the other tooling right so sure let's let's keep going so this is also prompted me to install that framework 472 13 Pack and I've done it for a SDK then in 3048 so I don't need on the framework I'm going to be doing that at 7 development so let's just remove that but hey you cannot do that because this is required by a bunch of other components that are having pre-selected for me so again I am stuck with that and so I cannot unselect this okay so let's keep going so I don't need it on this case so that's fine keep going keep going and this is one of the other things that really bothers me why do I have to install things for SQL Server if I may not even be using SQL Server let's say I'm going to be using Cosmos TV or mongodb or something completely different right why do I have to install anything for SQL Server so I'm going to unselect CLR types for SQL server and guess what I could have done select it right uh connectivity polishing tools I can download select it container development tools I cannot unselect it right is Express I have not used IX Express in years uh right this this day for dotnet development what you would be using is a Caster development server right why why do I need to be installing is Express but you have to install it right on any of these things so this is one of those things that really really bothers me like why do I have to install so many components when the only thing that I want to do is start writing my 8 Minute core applications right so yeah so those are the things that really bother me about this installation experience and I have not even started installing this thing but uh so yeah let's say that we're going to just go with this because we don't have any more options and one thing that I'm also going to do is to open up a little a timer here right just to get a sense of how much time this is going to take in in a machine like mine right and so let me go back here and I'm going to click on install okay and so let's go ahead and start the timer okay and let's see how much time this is actually going to take all right it's all installation just completed and I'm going to click and pause here and visual studio is actually opening in my other screen here let me show you this opening right there and so but yeah I mean notice this it took 6 minutes 35 seconds to install this this entire version of visual studio in my box right and so which you might consider it is a fast installation time uh but uh consider how much space this this took and let's also compare we're going to compare this uh with uh with Visual Studio code right and how much you can expect there and you can see that yeah Visual Studio it just open here it is ready to for us to start to start using it and but now let's let's compare this with a visual studio code so let me just close this and let me also close the people Studio installer over there and let's open up the visual studio code um installation so I'll double click on this and this opens up I'm going to say I accept okay I'll click on next let me actually minimize this for a moment and these and uh yeah so location that's fine uh yeah I mean that's fine uh do we want to register yes at the patches click on next and just like with the blue visual studio uh we're going to do our timer but before doing that I mean notice that I don't have any more options right this is just uh just Visual Studio code uh and nothing else and of course uh one thing that Visual Studio is doing for us is installing all the.net SDK and all these other tuning for.net for us uh which makes sense uh and we which is something that we'll also have to have to do ourselves as we go through this installation so I'll go ahead and start my my install before let's just bring in this timer here let's go ahead and refresh this and I'll say install right start timer let's see how much time this actually takes all right so yeah installation completed and then if I just click finish here I'll be taken into the previously called initial screen over here as you can see uh there you go so we have episode Circle installed it took no more than about 16 seconds to install uh but of course to be fair we don't have any any tooling at this point for actual data development right in this case it's just Visual Studio code so to be on pair with the visual studio experience we also have to install data net SDK so let's actually bring in the net SDK screen now over here this is the the download page for the.net SDK and I'm going to go ahead and download the.net 7 SDK so I'll click on this link here to download so download starts let's just do that that should take just a couple of seconds okay I click on the installer here we are let's go ahead and install this okay let's continue our timer here of course timer keeps going just to add to the additional installation time okay and while this happens let me just close the browser there all right so installation a completed and um yeah I'll just click on close as you can see we have not even reached one minute of installation between visual code and then.net SDK and but of course we may also want to have a little bit of more uh actual c-sharp coding features in business to the code that are not fulfilled either values to the code or even with the.net SDK that we may still be missing right so what I'm going to do is just look for the extension The one extension that you're always going to need for developing C sharp applications in Visual Studio code so I'm going to go into Visual Studio code into the extension hover over here and I'm going to be looking for the c-sharp extension all right so this is this is the one extension we provided by Microsoft that enables all sorts of productivity features a 4C sharp core development in your box and yeah I mean before I sell the extension let me just go ahead and start again our timer here so I'll start that I'll click on install okay so that's going to bring in that extension please give it a moment and it's your timer going on here and yeah it is complete the extension has been installed right we can see that it shows us our one Excel extension and at this point I'm pretty much ready to start coding my.net applications in Visual Studio code so in total how much time did it take a little bit more than a minute a minute and 12 seconds which is I think it is massive compared to the time that it took us to install a visual studio and also consider that in this experience here uh we did not have to make so many selections so many options to select components and stuff all we did was install just the editor.sdk just one extension and we're good to go right plus I can guarantee you that the space needed for this is really really low as compared to the space that we needed to install a visual studio and if you're curious about the actual space needed for visual studio code uh let me show you this uh here's my C drive over here and visual studio code will be located in the local updata location here if you go into programs Visual Studio code this is the installation of Visual Studio code right here and if you just look at the space very quickly uh let's do properties and you can see right here how much space this is taking as compared to the many gigabytes that we're asked to install visual studio right so it's a massive difference and um yeah and I just complain because there's people that people that may not have that much space available right and so that can make a significant difference in the sense of can you use Visual Studio or Visual Studio code right and and like I said you don't need that many components to develop other applications you just need a good editor.net SDK maybe some extension and that should be good for you to start developing your dot end applications let's now look at the update experience of both of these tools because this is something that you will have to do every few weeks or sometimes more than once in a week and it is good to be in the latest version of these tools because they will bring uh either bug fixes or security updates or even new features that are going to improve your overall developer experience right so you want to have the latest version always and so but it's good to see how much time it will take to perform this updating in both tools so on the left side I have visual studio and on the right side I have Visual Studio code and you can see that both of them are ready for an update you can see the update indicator right here and over here also for obviously the code and uh before doing the update let's just check very quickly what version we have of each of these tools uh so if you go to help about Visual Studio you're going to see that I am using version 17.4.0 official studio and then if you go into let's say Visual Studio code help about this is going to be version 1.73.1 all right and so those versions are kind of close in the sense of when they released each of these tools which is a few weeks ago in my case when I'm recording this so they were kind of the same age if if so and so so let's start with visual studio and let's see what happens so I'm going to go ahead and click over here I'm going to click on view details okay and that's going to open up our Visual Studio installer which is going to show us what a what version we're going to move into as you can see we are moving into version 17.4.3 all right so I'm going to click click update and of course this is going to prompt us to actually close this studio so that the update can actually happen and um before doing that definitely just go ahead and minimize this to the code and just for fun let me open up a timer here so that we can take get an idea of how much time this will actually take okay so I'm going to say continue I'll start my timer here and let's see how much time this update is going to take now just to be fair I only installed a 8 Minute core workload in visa for visual studio so that they are kind of similar uh with us to the code in terms of what components are actually installed right so this should only be updating a components for 8 Minute core all right so stop and the update has completed as you can see we are now in the latest version and uh yeah here you can see how much time it actually took three to three minutes and 24 seconds uh to get Visual Studio updated to the latest version okay and let me go ahead and click close installer now okay and let me put this to the back and what it was uh so yeah so that's how much time you can expect A View to update uh in the case of just the 8 Minute core workload and of course in a machine and like the one that I have right now so now let's take a look at Visual Studio code so let me bring back we'll do the code over here and let's go ahead and do a very a very similar exercise right so I'm going to go ahead and click in the in the notification over here I'll click on uh restart update and before doing that let me actually just grab my timer over here I'm going to reset it okay and now let's go ahead and do restart update and I'll start my timer now and uh oh stop it is updated now yeah that's how fast Visual Studio code is and uh well the fact is that this will do the code proactively actually download it it update it for me in the background right so that was already there so all it had to do is just restart and that will start bringing the brand new update but that's kind of the experience that you can expect with Visual Studio code right and that's one of the reasons one of the other reasons that I really like Visual Studio code because it is it is really really fast in terms of a performing update right like I said this is something that you'll have to do every few weeks or every few days sometimes and I don't really like having to wait and even those three or four minutes uh for the tool to get updated and in fact this video sometimes will actually require you to restart the entire machine right to acquired update depending on the components that you have installed in your box right in this case you didn't record it sometimes it might need a business Twitter code is just incredibly fast so it's almost you almost waste really no time to do an update so really like this will do the code because of this the next area that I think we should cover between these these two tools is the performance area because the amount of resources that each of these tools are going to be using from your machine is going to be very very different and not everybody has the amount of resources that are required for at least one of these tools so here on the left side what I have is my terminal in my projects directory where if I tier I have a bunch of Visual Studio Solutions or call bases that I want to show you and what happens as we start going into the code on the right side I'm showing you my task manager with my memory usage right now and what we're going to do is actually just so you can get an initial idea this is how much memory I'm using right now before doing anything and we're actually going to switch into the processes area here so that you can see how the different processes for Pixel Studio the studio code start spinning up over there so I'm going to switch first let's go with a very small solution this one here to do API and this one this is one that I found on GitHub it shows many of the different projects of that you can create with.net and HP net core and uh but it's still a small solution so let me just open up the solution that we have here to do API sln so this is going to go ahead and open my visual studio you can see it is opening and it should load in a moment yeah there it is let me put this on the left side and notice that how Visual Studio starts opening up here and quickly it starts climbing up in memory usage notice that these are ready beyond the one Gigabyte usage so without doing much just by opening this solution which is very small just five projects we are already using more than one gigabyte just for this one solution now let's compare that with Visual Studio code so let me go back to my terminal over here what I'm going to do is just type code Dot and this should open Visual Studio code in that exact location so it's right here there you go now I'm going to close that and this little code shows up over here and let's see how much a memory we are using something let me just close this and close that and let's do let me do this let's highlight memory usage right here not even 600 megabytes which is a about half of the memory that we are consuming from a visual studio right now right so here's for comparison both of them now it may not seem like a big difference but things start compounding as you start working on with more and more products because usually uh people will have not just one solution but multiple Solutions open for the different products that they're working on right and so let's see what happens if we start opening more more projects so in this case let me just go down into my project selector once again and I'm going to go into my e-shelf on containers project here and I'll call into SRC and I'm going to open up my Solutions this is a solution that has a bunch of other projects in here so let's see it's opening right now just get a moment for it to load okay so just load it okay right there and so let's see this one actually has 29 projects as you can see over here it's 29 projects and so it is loading also on the right side here so notice that this one is climbing up uh beyond the what was used for the first one uh just a little bit more but it just keeps climbing and climbing okay so at this point we are getting close to I guess three gigabytes of usage of on my machine and with those those two Visual Studio Solutions um this code right now is at 500 megabytes but we're going to now of course open up the same thing invisible Studio code just go up one directory and then let's open up that code base in code notice that uh code actually up is much faster right so isn't is in the order of a few seconds faster of course but yeah it's right there and notice the Real Steel code is not spinning up and not an instance of Visual Studio code we are still using I'm going to close this we're still using the exact same uh the exact same instance right here uh so that's why you see that this one instance started climbing up in terms of memory right now we're at one gigabyte uh yeah 1.2 gigabytes we used to the code uh but it's nowhere near the two the the sum of the two instances of Visual Studio that we have here right these two instances are still having a much more consumption of memory in the machine what these two equality remains very very steady and it exactly uh very um uh works very well it's very responsive right it's all good in Visual Studio code now Let's uh let's look at a really big solution right so what happens when you have dozens and dozens of early hundreds of projects loaded in a business Studio solution which where things really get uh get interesting so let me go back into my terminal here and I'm going to clean this and let's uh go up and let's go into my aspinet core uh directory here so this one here is the actual code base for asp.net core let's see what happens when we try to open this solution so I'll go ahead and open that okay so it is coming here now notice that this one here is actually going to take a while to load uh because of the number of projects so in visual studio uh the experience of opening opening your solution will would vary depending on the number of products right so you cannot really do anything here until uh this this whole loading of projects it completes and you can see that even it may get into this situation where Visual Studio is just not responsive at all until all these projects are are loaded right so but hopefully this should load in a moment should be done right now yep right there let's put this on the left side and then uh I think this instance here is going to be the very first one on the top here and notice that this is going to start climbing up more and more as we also starts doing uh I don't know starts doing things behind the scenes uh for all the all the language support and different productivity improvements in Visual Studio but notice that this is already at let's see this is three gigabytes right now and it will keep climbing right keep keep climbing and in fact let me show you my performance tab over here notice how memory keeps keeps climbing in this case because of the usage of pistol studio right and then uh interestingly CPU is also going crazy here I mean notice we're using 100 CPU here uh but it's half of it is just on this Visual Studio instance so what's going on there we are not doing anything we're just not doing anything at all and yet the machine is very busy dealing with with this Visual Studio solution right so at this point if we start adding these three solutions and let's actually adjust for fun let's open one more and by the way ah let's not forget this is record so let's open the same thing in Visual Studio code right so let's go ahead and do just code Dot okay and notice that we are right there no time to to to waste here so there's no need even with all those 500 projects we are ready in the visual studio code uh interface right here and we're ready to start a doing whatever we need to do with all of our code over here so the experience of opening a brand new uh of opening a code basic those two code is really fast it's really really fast right so there's no waiting and no delaying no no weird Frozen things uh it's just fast and notice also over here that our memory usage of Visual Studio code is is just about 1.5 gigabytes right there right while Visual Studio is already reaching a more than five gigabytes just in that one solution right which I get is a it's a big solution it's not everybody is going to have 500 projects uh but I have had the chance to work in progress that have dozens and dozens of products in a single solution and it just becomes a problem as you start adding more and more and more it is more and more time that you have to take anytime you have to open that solution and so yeah just for fun let's open up one more one more solution here so let's see we're going to go for our clean architecture a solution that I have here I'll open up that okay so it's opening up this one uh it doesn't have really that damage project so you should open fairly fast hopefully yeah so just waiting here yep there it is here we have it on the left side okay and it's coming up here on the right side uh which already just climbing up it's likely it's going to go across one gigabyte because why not right without us doing anything we're going to do the same thing with code here's code opening up same solution right same code base right there here's code climbing up a little bit more we make it to two gigabytes but it's not going to be anywhere close to the sum of all of the other bills to your solutions that you can see on the right side and so this is interesting for me and very important because like I said not everybody has the amount of resources that in this case I have so if I go down into performance of course I have 32 gigabytes right but notice where we are right now as compared to where we were when we started uh we started this section of the video right and so if you're working with only let's say 16 gigabytes right which will be common in a laptop or even less than that this is going to become a problem right you cannot really use a visual studio or not use it that much uh because of the amount of reasons it is consumed well this is the code it's just fine right it works just fine and so now let me go quickly back into this Visual Studio what I'm going to do now is just close all instances official Studio to see how much memory we can reclaim just by closing this solution so I'm going to to use going to my taskbar I'm going to say just close all windows for visual studio so that's going to close all visual Studios and then let's see what happens without memory usage as Visual Studio goes away so all of our musical Studio visual two solutions are now closed and so notice how much we are saving here right here uh by it just uh just closing those Solutions right so it's a massive amount of memory being reclaimed by doing that and now at the same time let me let me now close all of my visual studio codes I'm going to just close all of those close and let's see how much memory we're reclaiming by doing that let's give it a second and there you go so here we can see this is the amount of memory that we're claiming right there okay not that much because we didn't use that much anyways right so keep this in mind as you choose between visual studio just do a code uh depending on the amount of resources that you have available it may be not really a good option to call Visual Studio because the code works just fine even in a more constrained environments right and even then even if you have a good machine like one that I have as you have more projects it will take more and more time to be able to start actually coding while this do the code is just it just happens right away in this area that I'd like to cover as part of this comparison is Visual Studio Solutions and so as you may know Solutions are really just an artifact of Visual Studio that has been used for grouping a series of projects together in the IDE so that you can work on them right and they're actually required or the default way of working um with products in Visual Studio here what I have is a one Visual Studio solution that I found on the web in GitHub this is the eShop on containers solution and this is uh this is one that showcases a different set of microservices and how they can operate and work together in a kind of an end-to-end application that goes from the microservices to the to the front end and even including things like API gateways and stuff right and so if you if we open this this is Source directory you're going to see the different folders for API gateways a bunch of building blocks are being used by the microservices the actual microservices in this location here a bunch of web apps right that are going to be interacting with those microservices and then a folder here for tests and then if we collapse these other ones let me collapse this for a moment if you go into Services you're going to see like I said these are different microservices and each one has a different set of folders depending on the business of each of the microservices right now let me Focus here now in the ordering one uh because the thing is uh that what happens usually is that a as you start having more and more projects in your Solutions uh there may be indicates that some people may not need to work on all of these code base all the time right so for instance if I am the developer that that's in charge of the ordering or the ordering microservice uh there's no need for me to be loading all the product for all the services and even API gateways and all the other stuff all the time because that just consumes time right as we have seen as you have more projects episode 2 is going to take more time to load right and so it's just more things to build and compile and so I'd like to do something about it but before that let's just make sure that everything here is actually built in so let me just go ahead and do build build solution all right so let's make sure that everything is building properly and then what I'm going to do is ask people they like to do is just create another solution that only has uh actually I'm not created but I already have this solution ready but I'm going to open this solution that only has a project required for the ordering a microservice so yeah as you can see everything is building just fine and so what I'm going to do is just close this and here I am in the directory where I have that solution I also have another solution that is called ordering service sln so I'm going to open that one so ordering service at sln and like I said this solution is going to have only the price required for the ordering microservice so that allows me to have a much more uh simplified environment and I only have to build the things that I have to work on so it loads faster it builds faster and I can browse the code faster right so as you can see this has a only the ordering microservice with the tests and this this five products in there and also some building blocks that are required by the mega Services right if I build this let's make sure this is also building fine 12-bit solution and then yeah so everything is building properly okay and so as I am working in my ordering microservice it turns away that now I need to introduce a brand new feature which is going to be let's say Telemetry right and this is a kind of a fictional scenario but I want to show you what what happens here and I saw I need to introduce telement into this to this solution what I'm going to do is just add a brand new class Library that's going to have my Telemetry my emit Matrix API right that my Microsoft is going to start using what I'm going to do is just right click in order here I'm going to say add new project and this is going to be a simple class Library so I'm going to select that on the left side class Library and so let's pick the right location for this is going to be under Services ordering uh select folder let's name this ordering dot telemetry all right so ordering the Telemetry is going to be our telemetry thing and then everything here is actually using.net6 so we're going to stick to the net6 make sure that things work properly so create that so this is going to create that brand new project you can see it right here and first thing we're going to do is just rename this class 1 into something more meaningful like metrics emitter so that's going to be our our class here I'll say yes so that we get that name over there and then just before coding it we're going to also fix the name space which is distance not making sense let me just fix that by grabbing the name space from ordering API I'll go into controllers or the controller let me just grab this name space over here Services okay so that's that there so I should delete the writing space now what is this class going to do all it's going to do is just have one method that is going to be used to just emit a successful metric right supposedly so I'm going to add public static void amid success all right and so we're not going to actually implement this we're just going to say emit this has here but what the point that I want to make is that now we're going to go into our orders controller and then at this point let me just minimize we'll collapse this a little bit and that and hearing all this control what we want to do is down here in this ship order async method uh just before returning let's say over here uh we want to be able to emit that that Telemetry right so what we're going to do is of course if we need to have a reference between this ordering API and our running project so I'm going to right click in order API I'm going to say add product reference I'm going to say order in the Telemetry I'll hit OK so that gives me access to the tags you find it over there so now I will be able to say uh of course well before doing that let me go back here and then let's make sure this is static this is going to be a static class a static method so now I can say Matrix emitter Dot emit success right okay so now supposedly my API is able to admit a success just before returning anytime we successfully shipped an order right and so let's just make sure that this is still building properly I'll go ahead and say build okay uh building API yep it's building properly no no issues there and the next thing that I'm going to do is just make sure that these these changes are stated for for commit later on we're not going to commit this but I just want to at least stage this right all my changes in there and now what I'm going to do is just get out of this solution because this is this is my solution right I I am the owner of the ordering microservice so this works for me but other team members are not going to be really interested in the solution at all right so now I'm back in my terminal here and what I'm going to do is just to simulate what will happen for somebody that comes in for the first time and then it's going to open the main solution that we have here so what I'm going to do is just do a geek clean Dash xdf just clean everything here that's temporal here especially all of the bin OVA directories right all these things are temporarily generated by Visual Studio or by.net as you build things and so what I'm going to do is just go back to our original solution the each other container services and web apps sln so I'm going to go back here okay so opens and so all right here we are solution Explorer right and so here we're back into our list of a microservices and so first thing we're going to try to do here is to make sure that we can build the solution right so I'm going to go ahead and say build build solution okay and so let's see what happens okay and so this did not succeed unfortunately and let's see if we can get a bit lock over here uh yeah so we have a bunch of products that are failing and we go to error list maybe we can focus on the errors over there yep and so in fact it is complaining right because it is saying unable to find project information for the project something something ordering ordering the Telemetry ordering the limited which happens to be the product that we just added and we added to the solution right so but if you go to Services ordering uh over here there is as you can see there is no telemedi project is not here and why is that because we added that to the old solution we didn't add it to the main solution right and so what we did by doing this is we just broke the ability of everybody else in the team to be able to build the complete solution here because we added a product only to one to the solution that we are working on right now this is not just a problem for for your developers it's also a problem if you have a CI LCD system in place you are ready and that's if the system depends on the solution uh is only is also going to result in a broken build because the solution is not building anymore and so I have seen this happening many times in my years working with visual studio and uh and of course what what you want to do here is just go ahead and communicate with the original developer and say hey can you please add your new product into the main solution that everybody is using right and which is fine but uh this should not be a product right we should not get into this this situation at all and the fact is that you should realize that Solutions are not really required for dot-in development or SB Network you don't need to use Solutions and you don't need to get into this mess to start with right and also if you step back the only reason why this uh this developer let's say me wanted to have my own solution is because it just takes too much time to open this it takes too much time to build the whole thing right uh it just takes too much time to do whatever everything here in Visual Studio by having more and more projects so how can we go and get out of this situation and out of this product all together so let me just close this now let's go into Visual Studio code and for this let me just go up one directory and I'm going to just say code Dot and here we have our our code base now in business to the code right and you can see that we have all of our code available here right including our two solutions we're on the left side here and so we are going to say not now we are not going to be using that feature fields to record right now and so the thing is that what I want you to realize is that to start with I mean we just opened this this code base here without using the solution right so the solution was not required at all for this and in fact what we're going to do is just get rid of both the alternating service and the issue 1 container Solutions those are going away right because they are not needed at all and so now you're going to wonder well if they are not needed how are you going to build this this entire thing because we don't want to be building one by one each of the operators right so that that makes sense so one thing I want to show you is a is one and nice a tool or SDK framework I guess which is called the the build traversal and this is a very nice uh this is a very nice a tooling or I guess newer package that you can use to actually build the entire code base without the use of a solution so let me actually show you this page over here so this is the the page for the MS build sdks and you can see the actual location over there right here this is where you're going to be able to to find it and so as you see here you're going to get all the details about this but what this allows you to do is to Define a simple approach a file that is going to have this kind of um a Glock pattern that instructs the compiler into how to build every single product that is in your code base right so with this you will not need to set up Solutions or have different solutions to physical base every single product that is in there will be able to to be built by these how do we use this so what you want to do is first let's go back to the code and so what I'm going to do is just Define a brand new file over here that I'm going to call uh build that proc and you can call this anyway and you want but it should have the that proc extension for a good convention and now what I'm going to do is just copy copy this uh this little example over here I'm going to copy that okay I'm going to place that here okay and then one thing that this is missing is actually the version of the build traversal that you want to use because you have to specify the version so if you just go back here and we are going to just copy the name of this I'm going to go into another tab I'm going to go into nougat.org and here I'm just going to log for a Microsoft build traversal and this is going to show me the latest version latest version E320 so I'm just going to copy that and back here I'm going to say Microsoft build traversal slash three to zero okay so that's the latest version at the time that I'm recording this and so what this as you can see but this pattern is saying go ahead and create kind of a tree map of product references that includes every single uh project that ends in proc which is really all of our projects right let's say for instance Services ordering ordering API like that and so you're going to see that this ends in CS product you can see that right here CS Pro so everything that ends in proc should be included here under the SRC directory right and so I'll say this and really that that's pretty much it with this in place you are able to build the entire gold base so if I just open my terminal now Ctrl J and I try to do a net build even with without having any solution in place I'll go ahead and do that and now uhnet build tool is able to find every single project in May call base without the need of a solution so so to start with there is no need for developers to start adding their own Solutions and even if they did so uh every other developer or even the CI system is able to go ahead and build an entire code base just by the fact that of having this blog file over here so there is no more a chance of of missing one project or another project in the solution because the solution is not needed at all to start with and so with this I I hope you get the idea that Solutions are not needed and especially when you're in the visual studio code which which is really folder basic right you can do everything you want in the folder and this simple very simple six lines file is going to be able to take care of the and for making sure that you you always have the ability to build everything in the cold base all the time without any problems the last reason why I prefer Visual Studio code over Visual Studio is because I believe it makes you a better.net developer and that's because it visual code allows you to then get a much and better understanding of how.net.net CLI works and that that will prove to be super super useful moving on and so to show that what we're going to do here is just to create a brand new project in both in Visual Studio to the code and just compare a little bit experience and see how far things are going to take us takes us with each of these editors so on the left side I have Visual Studio on the right side of Health view Studio code what I'm going to do is just go ahead and say file new a project what we're going to be creating here is a very simple a web application so it's going to be an infinite core web app the one that I have right here so I'm going to say next I'm going to pick the right directory for this which is going to be under the projects the projects and select that um the name of our project is going to be hello.net dot web and then the solution is going to be named hello.net.bs okay so I'm going to say next and for this we're going to be using.net 7 actually so done at 7 and the rest of the stuff we're going to leave it as is I'm going to say just create all right so our project has been created okay I'm going to close this start screen over there and so like I said this is a very simple web application and of course the typical flow here would be just to purify that things working properly right so as uh as a net developer starting with Visual Studio what you want to do here is just hit F5 Verizon which is I'm going to do right now you'll just hit a five okay so that's going to build the project as you can see there in the output and that that's going to start a debugging session and is also going to spin up a browser which is going to show me a super super simple uh UI here for my web application so this is going to be adding eraser Pages application so nothing nothing for fancy right and so yeah so you got our application created and up and running in just a few seconds right so that's fine now let's compare this with experience of Visual Studio code how would you do the same thing in Visual Studio code so here I have Visual Studio code on my right side over here and of course in build Studio code there's not such a thing as a file new project right because this vehicle is assigned for any kind of different coding environments so in this case what we're going to do is first create a directory we're just going to do it's going to be named hello.net.vs code that's going to be the the folder where we're going to create things so and so now we are there let me just open up visitor code in that location and that I can do by doing a file a open folder so I'm going to go into that location over here so the projects hello.net.vs code select folder okay I'll say just here and this opens up the this is called a UI in the context of that directory now I'm going to open up my terminal over here and I'll maximize this for a moment so that we can see better and so in the case of this to the code what you have to do here to create a brand new product is to actually use what we know as the net command line interface or Dot and CLI and that is available for you as soon as you installed ack so if you just type here.net you're going to get a little bit of information of what you can do with the.net command line tool you can also dot net info that's going to give you a little bit of information about the version that you have installed of.net which in my case is version 70101 all right now the thing is when you want to create a brand new project what you can do here is a first get kind of a list of all the project types that you want to that you're able to install so you can dotnet new list and this is going to give you a list of all the different projects that you are able to create with your.net SDK now in our case what we're interested in right now is really this one over here internet core web app okay this is eraser Pages app so that's the one that we want to create and so so to do that what we're going to do is just something as simple as and let me click this dot net new web app and then the name is going to be hello.net.web that's going to be our web app and I'll just hit enter and so that's going to go ahead and scaffold or generate all the files required for my project and as you can see on the left side that has array being created right there and if I go ahead and click let's say I click on program.cs and I'm going to close this terminal hi there what you're going to see is that the only server server just kicked off you can see that over here on the sharp it just kicked off and this is a server that enables all of the nice visual studio nice c-sharp intellisense in here and if I click just on this and this dialog that's going to spin up the dot vs code folder that brings in data Json launch notation which are required for you to be able to build and run a debug your Project's teacher projects in this studio code but really that's these are ready ready to go just like in visual studio and uh and again I can just go ahead and hit a five now this is going to go ahead and build the project and then it's going to start the product right away okay so it's starting and then once again I have my my page up and running right here now if I just close this now notice and let me minimize this notice that this is if if I wanted to do kind of a debugging session but I can always just stick to the terminal over here and while being here what I can do is just say dot net run and that's going to have of course I have to change tiers let me switch to hello.net.web and then I'll do.net run and that's going to go ahead and start my application right so that's not really I need 45 this is a running session without debugging so I could just copy this URL over here open my browser over there and here we are right so the project has a the page has loaded just fine now let's close this and let's stop that now as you can see you can do the the same thing both in visual studio and visual studio code right uh but the what I want to highlight here is that there are going to be situations where you don't have either of these IDs available either Visual Studio this little code if for any reason uh in your machine things are just not not set up properly right because for instance because Visual Studio is having some problems loading right it's just crashing for any reason which happens from time to time or if you don't have permissions in the machine to install these guides or if your machine doesn't have enough RAM for instance to load Visual Studio because it consumes so much RAM or you don't have enough space or for any reason you are not able to access any of these IDs what do you do right so in this in this case let me just close close this both of these close both of them okay and now you're left with your let's say just your terminal right so as a good the developer you should be able to steal and get things done without having to need a an entire IDE or even a code Editor to do your job right so and so for instance let's say that in this case we got a requirement and we have to make a very simple a small change into the index page of that application that we just created right but now we don't we won't but like I said we don't have any idea available right now we don't have email code editor what we're going to do well since we we know Visual Studio code and we are because we use Visual Studio code we are exposed to the.net CLI right away because that's what we use it to create a project and that's what we use it also to run the project uh we know that we can do this these things without an actual ID or code editor so for instance let me go into hello.net.vs code okay now as you remember this is what we have our code base and I'll actually go into adultnet.web this is where we have our files right and so if you wanted to make a change I mean to start with let's let's uh let's uh let's confirm that we can actually run the application and as you can see I am outside of Visual Studio code or visual studio and I can still do.net run right you can do the net run and uh my application is up and running if I just copy this I'm going to copy that URL open my browser over here hit enter here is my application right so I don't need an IDE to run my dot-in application and what I'm actually going to do is just keep this page open on the right side over there and I bring my terminal to the left side okay so I'll do Ctrl C and then I'll do there again and so the requirement is that we want to change and just just do a small change to this text here we want it to say something different and so what we're going to do is just a make a change so what I'll do is go into the Pages directory okay so what we have here we have all these files and I know that my HTML file is going to be so notepad this is going to be in a index.cs HTML so that's the file that has a my HTML code it's right here right so this is the one that has the welcome message on the right side okay so if you want to make a change all I have to do and just by using notepad is to uh just make the change so I'm going to just say welcome to this site okay that's all I'm going to do so I'm going to hit save okay and now what I can do is just restart my application and for that what I'm going to do is actually just go into another um another terminal just keep things simple I'm going to copy the location I'm going to go into that location I'm going to say.net run okay button run okay application really starts if I refresh this now you can see that the title has changed right welcome to this site now the cool thing with.net and as you learn about the the silai is that you can even improve even further this disabled flow so for instance instead of doing.net run all the time what you can do is dot net the watch right so that then watch right there is going to be watching for any changes that we make into our cool base right and you can see the side is up and running there and now if if what I'm going to do is let me actually make this a bit smaller and let's bring my notepad over there let's see if we can accommodate it in the right place apps there okay yeah just like that I'm going to say dot net rocks okay that's going to be my my text and I'm going to save this so file save notice that.net.net a CLI notices the change and yeah I mean it just changed it right away right so I am able to have a simple but still nice flow here where I can make changes to my application without ever needing an IDE or uh or a code editor now of course this this is this functionality of hot reload is also available in Visual Studio definitely it is but I didn't need to install a tons and tons of gigabytes of Tooling in my box or or use tons and tons of memory or space right uh to be able to to get to this experience here right and this not not just worked for HTML5 right this is a very simple HTML but what if I have to change something like it's a C sharp based a file so let me actually go back to my first Powershell let me now open so I'll do notepad it's going to be index.html.cs okay so this is my code file right this represents the c-sharp code behind that page so I'm going to put that over here so we can see now what I'm going to do is just something very very simple in the oncat in the on get method here which is the one that's invoked when the page is about to be rendered on the server side we're going to just say we're going to be using this logger which is the one that you can use to log information to to either to your console or to any of the sources I have been configured for logging I'm going to say logger.log information and I'm just going to say hello there all right that's all it's going to do okay just hello there so now I'm going to go ahead and also just save here okay and then back here as you can see the it was actually super fast but the file changed it notice that the file changes over here hold reload detected the change and the change is right there and if I start refreshing this page you're going to see that hello there starts popping up on the left side right so how to load even worked for the the C sharp code not just HTML code and again I am able to do all this stuff because I know how to use it.net and that's because I got used to it because I had to do Visual Studio code and not just Visual Studio where everything is kind of hidden from me in terms of this additional tooling that I can use to manage this now I can do even more things with this right so for instance if I wanted to I could go back here and I could create even more types of products like for instance if I just go back here uh if I need it to create some tests for my application I could just now just dot net new X unit and then we're going to name this project hello.net.web.tests hit enter and this is going to include my X unit tests and of which I'm not going to actually write a test right now but there's one built in into that code generated code so I'm going to go into the net.web.test and if you wanted to just run my tests without having to have any code editor or any IDE I can just say.net test and that's going to go ahead and run any tests that have been defined in that project this is just one simple test in there we're going to take a look in a moment but as you can see it was able to run my test without ever needing to again go back to an entire IDE now if we go back into Visual Studio code so I'm going to do code here and perhaps I'm actually just going to back here and just just stop this for a moment and then back to this one I'm going to do contact go back to this video code and you're going to be able to see that now we have these two projects right so there's one for my web application and one for my test and that test that we just saw is just absolutely nothing right now but I just wanted to prove the point that we can create that test and for the common way now now in the CLI is not important just for your local development in this case where you don't have an IDE it's also interesting for the cases where you want to move a Beyond just a local box and you want to do things like for instance establishing a cicd process or even adjust a CI process for your applications at any time you're checking your changes gear to your Source control let's say GitHub uh the the the CI process verifies that that course compiles and that tests are running and that everything is running going just fine so what we have to do to enable that first thing we're going to do is to actually create a build.proc file like the one that we created in in the other demo so that we can we were able to build the entire thing in one shot right and to do that we're going to do is you go back into my file explorer here and I'm going to go remember we did this in the issue one containers demo so we have Builder plug over there so I'm just going to copy that guy so copy this I'll go into projects and into hello.net vs code and I'm going to paste that over here there you go build the progress is right here now we don't have an SRC directory in this case so I'm going to just simplify this by removing that okay so now we have our Builder proc we don't need again we don't need a solution for any of this and so now if I open my terminal and I just say.net build without having any solution this is going to be able to build both of the projects that are available in my code base just by doing that right and even more I can just I can also dot net test and that's going to run any tests available in the price that are included in my code base right so yeah this of course expected it passed Now by having now that we have this what we want to do is just push this into into a source control location so we can see how to enable a cic process so to do that what I did already is I prepared over here I prepared a ready a GitHub repository that I called hello.net.s code we're going to do is just checking this code over there so to do that we're just going to follow these instructions here so first thing we're going to do is just get in it okay here in the terminal get in it so this initializes the code base a four what we're going to is for being able to commit and push it right and so but the only thing is that we may have more more Files about to check in here than the ones that we want to check in so for instance everything that's inside um the OVA directory right this guy's here that should not be checked in because those are temporal files are only required in your box as you're building things right so this mean directory or this OVA directory and same for the library are not going to be needed so how can we just exclude that from from a from a git as you know you may know if that's where you want to use a git ignore file and in terms of it that you can also use it.net CLI to create one of those so let me collapse this a little bit and so notice that if you do.net new list there's one option here going up there's one option to create a git ignore file so it's growing up here that option is available right here .net get enough file so really all I have to do at this point is just say clean this dot net new git ignore and that by itself is going to create this brand new file over here that get ignore file that is already able to exclude many of the very common things that are that you won't include as a.net a developer in the application right and notice now that my my bin and OVA directories are here are are no longer included in the faster I'm going to be checked in there are grayed out that means that they're not going to be included so and the files are much less now so now I feel much much more confident about about this so I'm going to do is just include some comment here this is going to be my first comment I'll do a comment here I'll say yes all right I'll close all my files and then open my terminal and then back into GitHub over here uh will not have a reading for now and then I'll go I'll rename my Branch into a main branch why not that that that's fine so my branch is now Main and then next thing I'm going to connect my local box with the remote by using this line here okay so now my remote is that location on GitHub and so anything I push is going to go by default into that location and then lastly I can go ahead and do my push I'll just copy this last line over here over there right so now the code is using GitHub and we can configure that by going back over here let me show you that over there if I just refresh this my code is now on GitHub everything is there it's just one minute ago all right but the cool thing is that now that I have this here I can very easily establish a cic process with Git of actions so if we go into the actions tab over here what we can do is to select between these templates for whatever makes most sense for what we want to do in this case what really makes more sense is this one here in continuous integration the.net one over here I'll click on configure and this is going to prepare us or generate kind of a.net jaml file uh that has the initial content here and I won't go into much details about what's going on here but what you want to know is that uh what this means is that anytime that A Change Is checked in or merged into the main branch in this and this code base and that's that that's what this guy says here uh the following set of steps are going to be taken directly in in the GitHub site right and so we have a build job over here that's going to be running in a Ubuntu machine and then it has a bunch of steps first step is to go ahead and check out the code next step is to set up that into the machine to make sure that we have the.net.net SDK available over there in our case since we did a.n7 application that we want to do is to do edited version 7 7 0x and but then comes the interesting part uh we have these three steps here that rely on the.net CLI uh so if I was a visual studio developer I may not even be aware of the fact that there is a.net CLI so I would be a little bit lost here I don't know what to do but since I am a visual studio code developer I do know about the dot ncli and I am at least a little bit exposed to it right so this doesn't really surprise me so this what this is telling is that we're going to have a step for restoring all the dependencies no dependencies of our project then we have another step to uh going doing the actual build process and last step is going to run all of the tests that we have available and so uh the way that our code base is a structured this should just work just fine and because we have the build.brock file right so everything should work at the root so we will we will be able to restore and then build with no restore means since we are ready to restore does not do the restore again right we can just go ahead and build and when we're done with that we can go ahead and do the.net test so we just did in my box right and there's no need to build it um but and we want to do normal velocity so this should just work as it is and I am happy with this because I am familiar with the.net CLI and so now we have this what we can do is just a click on start comment and then I'll accept the defaults over there and then I'll say committee file all right and so the channel has been created now uh what you're going to notice is that if we go into actions there's a brand new action kicking off right here so create.net because I just committed some changes in there there's a new file in there it notices that and it kicks off this process which right now I just have one job over here which is the build job there's already running and that is following one by one all of the steps that we Define it in that Gmail file so right now you can see it is restoring the dependencies right be able to build a block file then it will go ahead and build the project to make sure that everything compiles we're not breaking the build and finally it's going to go ahead and run all the tests as you can see it runs and it completed so this was a full success and if you if you go back to visual studio code and you do hit pull you're going to see on the left side that are brand new bsco.github.net Java file is available over here also because we checked in in the UI of GitHub it was checked into the code base and now it's available over here okay uh but uh yeah I mean that's what I wanted to show you because we were able to do this process with a with a lot of confidence because of the fact that we are exposed to the.net TI right so as a view Studio code developer you are exposed to that and that gives you a lot of more opportunities to unblock yourself in things that are fairly trivial really but when you are more of a visual studio developer you're more constrained into a doing the magic of Visual Studio but never really learning a little bit more deep into what you can do uh with the.net tooling I hope that host gratify my reasoning behind always using BS code in all my internet tutorials have you experienced similar issues as me please let me know in the comments I would love to know your experiences with BS code and Diesel studio also check out my site for additional resources design for top 10 developers ready to take the next steps in their careers and don't forget to subscribe to my channel so you are the first to know whenever I publish new videos see you next time
Info
Channel: Julio Casal
Views: 6,415
Rating: undefined out of 5
Keywords: dotnet, vscode, visual studio code, visual studio, asp.net core, .net
Id: FHnwVsDRu3k
Channel Id: undefined
Length: 68min 44sec (4124 seconds)
Published: Tue Jan 03 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.