CLI Commands for .NET Core | Code with Bapu

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi everyone welcome to another Topic in this session we are going to understand how to work with net core application by using the CLI commands Okay so I'm going to create a new project and uh that project we will create by using the CLI commands so what are all commands we need to consider uh in order to work with the net so let me just open it okay I hope uh my notepad is visible to you now in order to create a new project you will have to use this command dotnet space new and your new project type so there are several types of project we can create in net like you can create console application you can create web application then then you can create class Library appre okay so this type of projects we can create in the net so you can just write the command like net new console if you write console it will just create console application for you okay so this is your first command second command uh like see uh in yournet core project you you may have to add some net packages third party Nate packages right so if you want to restore those packages you can use net Resto okay it will just download all the dependencies for your project okay once you're done with restore you can create net build so net build will just compile your project will compile all the uh classes which you have created and eventually we'll create the D file or EXT file so this is for build and there is one more net Run net run command will actually run your project okay now whatever source code you have created or written if you want to publish that somewhere okay if you want to publish your code on the i i server or any other server Docker or something so you will have to create the artifacts okay publishable files build so that itex you can create by using the net publish net publish okay while publishing your sources you can mention the type release type whether it is release or debug so that we can just mention like this okay this is the command then uh if you want to add any Newgate package to your project you can use this command net add package and then your package name okay so this is the command to add a new nouet package what is nouet package nouet package are third party packages which are developed to reuse the same logic which is developed by someone else in your project like I wanted to serialize and deserialize JavaScript sorry Json object okay I wanted to convert C object to the Json Json string to the cop object so for this you don't have to write your own logic okay it is already written in some packages like Newton soft Json if you install that package in your project you don't have to rewrite this functionality again and again okay how to install that package you can just use this command okay here if you go npm install Newton sof Jon okay so this is the command install and use packages in net okay this one net add package newtonsoft Json and this is the version okay same command I just provided here net add package and your package so this is how you can just add the packages in your project it is supported in the net okay net CLI so too many commands are there if you just want to work with net core uh CLI you can just use these commands Okay so let's get started uh let create the new new project here so if I go here on this folder right click and then you can open your CMD command prompt like this okay let me share command prom window as well okay I hope the command prom window is visible to you we are in this path and here if you create net new project type is console okay Enter so once you enter it will just create the console application for you okay you can see the template console application was created successfully okay where it is created it is created into the same project see object. net CS Pro program. CS file is there okay it automatically got created so this class is also got created automatically okay now you can just open this project in Vis Studio code like this so code space Dot enter so visual studio code is a open source ID which will help you to work with the net projects if you are going to use command line arguments sorry CLI okay so this will be your editor if I click on the program.cs file you can see uh hello Word file is there okay program.cs this is console. right hell uh text uh program code already created byet application now let's change this code something like I just wanted to change hello welcome okay so this way I just wanted to run this project how I can run this project what are all things I need to do which command I need to run okay it is just asking you to install the CF language extension you can just install it because it will help you to identify the syntax or identify the compile time errors and all so just install this extension it is open source okay it is installing so meanwhile just go back here now I wanted to build this project okay so how to build this project open this terminal and here just write this command I already share some commands here so so second command is net build right so you can just do dot net build this one word so it will just build the project and create the D file you can see it started the building determining the project to restore All Pro up to date for ReStore now it is compiling the sources okay so why we require to build the project because whatever code you have written in human readable language that will converted into the machine readable language okay and it will eventually create the exe file as well as dll file so exe file is nothing but your executable file which will execute or run or your on your Windows machine D file can be your companion file means you can use the D file into another project see project build successfully now if I go to the fold folder you can see bin folder also inside the bin you will find debug inside the debug you will find D file as well as EX file these are executable files or we can call them as a uh give me a minute we can call them as a output files are you guys not seeing my visual studio code no sir no okay sorry uh let me share it again yeah is it visible okay great so you can see what I was saying in the visual studio code I just open the project which we have created right so here once you open your project you will see program.cs file is automatically got created if I open this file here you can actually write the cop code okay it will ask you to install the extension for cop so just make sure to install it because it will help you to identify syntax error or it will help you to uh provide the compile time errors uh during the pro program only warnings and errors everything so just install it next thing is once you done with your project you can just run some commands like I wanted to build this project so how I can build this project so go here open your terminal like this Min and here you can just enter the command net build okay let me do again like this so if you enter net build it will comp start building your project you can see uh it is restoring the packages first it it confirms all the packages are now restor successfully and then after the build it has created One D file this is your output file where it is created it has created that file inside the bin folder this is your DL file okay so D file can be a companion project or it can be a self self executable project on different operating system like Mac obuntu or Linux on Windows it will use this exe file so this is another executable file output file for your project okay and build has been succeeded now I wanted to run this project how to run that project you can use another CLI command that Isn net run okay if you run this command then it will show you the output here only in the output window okay you can see hello welcome to netcore CLI got it so this is your output so this is how we can just run the project we can build the project and we can work with net core application by using the CI commands Okay we can do anything all the s commands if you know you don't have to use Visual Studio 2022 okay you can just work with the visual studio code only okay so this is how we can just create the net application by using the CLI you can create a new class like right click here okay plus not here plus let's say I have created one more class that math do CS okay whatever class you will write here you know we should have public class my name should be same in this class you can write the Constructor you can write properties you can write functions let's say I have created one function integer add integer a comma integer P okay this is your function and your output will be a + b now I wanted to call this add function from the program. Cs what I will do I will first of all create one output variable equal to new we need to create an instance of that class first right so new math and then we can call the function that is ADD function first parameter is let's say 10 second is 20 output should be 30 right so whatever output we can just print here addition is is equal to Output okay so this is how we can just uh create a classes we can same uh like a c or Visual Studio ID we can create a function here and we can call that function in the program.cs and we can whatever output we got we can just print that output on the console now let's build and run this project how to build again go to the terminal here you can do one thing first of all build your project net build and then you can run your project like this so you will see the output here you can see addition is 30 okay so there is no change at all you can work same like you are working with the visual studio okay only by using the visual studio code is it is open source you don't have to pay uh anything any uh amount to the Microsoft okay if you know the CLI commands in Visual Studio there are uh some buttons or visual uh Wizards are available like there is a build button then there is a run button all these things are available in the v studio so you don't have to use this command but if you know the command then that is more than uh enough like you don't have to work with Visual Studio okay so this is how we can just use CLI commands so in the next session we'll start working on the creating new projects for web API by using the visual studio ID okay so let me start the recording
Info
Channel: Code With Bapu
Views: 353
Rating: undefined out of 5
Keywords: programming, c programming language, c# (programming language), c programming, what is c sharp programming language, programming project ideas, c# programming, c language, c programming projects, c sharp, java programming language, c sharp tutorial, top programming language 2022, best programming language, how to learn programming, programming project, introduction to c# programming language, how to learn c# programming language, uses of c# programming language
Id: aOC5Iezot2k
Channel Id: undefined
Length: 16min 1sec (961 seconds)
Published: Wed Nov 29 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.