Create a solution from command line for an MVC project in Visual Studio code - VishalPatangay/My-devops-repo GitHub Wiki

Welcome to the My-devops-repo wiki!

//Create a new web project locally

C://Users/Visha/Source/Repos/azops_1

  1. Create a newe solution file from cmd dotnet new sln -n MyApp

  2. Create a new Web project dotnet new mvc -n MyApp.web

  3. Create a new Test project dotnet new mstest -n MyApp.Test

  4. Now add the reference to your solution:

dotnet sln add MyApp.Web\myapp.web.csproj dotnet sln add MyApp.Test\myapp.Test.csproj

The above will add the myappweb and myapp test projects to our solution. check in visual studio code now.

  1. You can open visual studio codefrom command line with below command: Command: code .

  2. Now initiate git in the same directory. Command: git init ---- creates an empty folder (.git) in the same folder where your source code proj is present.

  3. Build your solution now

command: dotnet build MyApp.sln

  1. Now run your web application(you may need to change to the directory where your webapp file is present) Command: dotnet run MyApp.web

when you say run here, the web server has initialised and it lists down the port where it is listening something like

now listening on https://localhost:5001 open a webbrowser and type this in url you will see the website opening.

  1. How to know the git status?

Command: git status

On branch master

No commits yet

Untracked files: (use "git add ..." to include in what will be committed) ../Git/ ../MyApp.Test/ ../MyApp.sln ./

nothing added to commit but untracked files present (use "git add" to track)

It tells us which branch we are in with no commits yet to Git.

  1. Add the project to staging using git add command. Command: git add .

  2. Now commit your files to Git repository COmmand: git commit -m "Init -This is a text displayed for each commit"

  3. Create a new branch Command:git branch -l - will give the list of all branches for this solution

Command: git branch myfeature- creates a new branch

  1. To Checkout(switch) the new branch created Command: git checkout myfeature

  2. Merge your branch to Master ** step 1: checkout master - git checkout master Step 2: git merge myfeature step 3: git log -v --graph to view the evolution of the changes. **

  3. git reset --hard of the branch This will reset the merged changes of the branch

⚠️ **GitHub.com Fallback** ⚠️