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
-
Create a newe solution file from cmd dotnet new sln -n MyApp
-
Create a new Web project dotnet new mvc -n MyApp.web
-
Create a new Test project dotnet new mstest -n MyApp.Test
-
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.
-
You can open visual studio codefrom command line with below command: Command: code .
-
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.
-
Build your solution now
command: dotnet build MyApp.sln
- 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.
- 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.
-
Add the project to staging using git add command. Command: git add .
-
Now commit your files to Git repository COmmand: git commit -m "Init -This is a text displayed for each commit"
-
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
-
To Checkout(switch) the new branch created Command: git checkout myfeature
-
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. **
-
git reset --hard of the branch This will reset the merged changes of the branch