- Azure DevOps Server 2019 Cookbook(Second Edition)
- Tarun Arora Utkarsh Shigihalli
- 557字
- 2021-06-24 14:18:35
How to do it...
- Open the Command Prompt and create a new working folder:
mkdir myWebApp
cd myWebApp
- In myWebApp, initialize a new Git repository:
init git
- Configure global settings for the name and email address to be used when committing in this Git repository:
git config --global user.name "Tarun Arora"
git config --global user.email "tarun.arora@contoso.com"
If you are working behind an enterprise proxy, you can make your Git repository proxy-aware by adding the proxy details in the Git global configuration file. There are different variations of this command that will allow you to set up an HTTP/HTTPS proxy (with username/password) and optionally bypass SSL verification. Run the below command to configure a proxy in your global git config.
git config --global http.proxy http://proxyUsername:proxyPassword@proxy.server.com:port
git config --global http.proxy http://proxyUsername:proxyPassword@proxy.server.com:port
- Create a new ASP.NET core application. The new command offers a collection of switches that can be used for language, authentication, and framework selection (more details can be found on Microsoft docs: https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-new?tabs=netcore2x):
dotnet new mvc
Launch Visual Studio Code in the context of the current working folder:
code .
- When the project opens up in Visual Studio Code, select Yes for the Required assets to build and debug are missing from 'MvcMovie'. Add them? warning message. Select Restore for the There are unresolved dependencies info message. Hit F5 to debug the application. Then, myWebApp will load in the browser, as shown in the following screenshot:
You'll notice that the .vscode folder has been added to your working folder. To avoid committing this folder into your Git repository, you can include this in the .gitignore file. With the .vscode folder selected, hit F1 to launch the command window in Visual Studio Code, type gitIgnore, and accept the option to include the selected folder in the .gitIgnore file:
- To stage and commit the newly created myWebApp project to your Git repository from Visual Studio Code, navigate to the Git icon from the left panel. Add a commit comment and commit the changes by clicking the checkmark icon. This will stage and commit the changes in one operation:
- Open Program.cs; you'll notice that Git lens decorates the classes and functions with the commit history and also brings this information inline to every line of code:
- To share your Git repository with others, it needs to be published to a remote repository. Create a new Git repository in the Azure DevOps Server's partsunlimited team project and call it myWebApp. Don't initialize the Git repository by adding a readme.md file.
If you have a reinitialized repository on the server that you want to associate with an unrelated local Git repository, you'll need to merge unrelated histories – refer to the There's more section to learn how to do this.
- Add the newly created Git repository in the Azure DevOps Server as the remote for the local Git repository:
git remote add origin http://Azure DevOps Server2018/Azure DevOps Server/DefaultCollection/PartsUnlimited/_git/MyWebApp
- In order to validate the URL of the remote git branch run the following command:
git origin -v
Visual Studio Code detects that the local Git repository is associated with a remote Git repository in Azure DevOps Server. It gives you the option to push the local changes to the origin right from within the Visual Studio Code status bar: