1.6. Cloning a C# Project

Follow along with the provided walkthroughs to learn how to clone repos into Visual Studio. Try it out on your own by cloning the LaunchCodeEducation/csharp-web-dev-datatypes repository page and fork the repository into your own GitHub account by selecting Fork from the top right of the page.

1.6.1. Windows Users

Clone a Git Repository in Visual Studio

Note the path where you save this repo.

1.6.2. Mac Users

Cloning an Existing Repo

Be sure to note the Target Folder where this repo is saved.

1.6.3. Exploring the Cloned Repo in Your Terminal

Once you have cloned it into Visual Studio, locate the repo using your terminal.

On a Windows machine, it is a path you saved your repo at. On a Mac, it’s in the Target Folder.

Once you find the repo, cd into it. Look for the Solution file which uses the .sln file type.

students-computer:csharp-web-dev-datatypes student$ ls
HelloMethods                 csharp-web-dev-datatypes.sln
TempConverter

Note

The csharp-web-dev-datatype solution contains 2 separate projects: HelloMethods and TempConverter. A single solution can hold multiple projects.

Try to open the solution using the command line prompt:

  • Windows Users: start *.sln
  • Mac Users: open *.sln

Return to the terminal. Locate your Program.cs file for the HelloMethods project. This will be contained in the project directory of the same name.

students-computer:csharp-web-dev-datatypes student$ ls
HelloMethods                 csharp-web-dev-datatypes.sln
TempConverter

students-computer:csharp-web-dev-datatypes student$ cd HelloMethods
students-computer:csharp-web-dev-datatypes student$ ls
HelloMethods.csproj  Message.cs              Program.cs

You have now stepped into the project files for HelloMethods. All of the files here are related to the HelloMethods project.

As you work with repos in this unit, some solutions may contain a single project and others may contain multiple.

1.6.4. How to Work with a Cloned Repo

We recommend using the terminal to open and work with your repos. You will be able to interact with git easily this way.

Use the terminal to locate the repo you wish to open. cd into the solution. You can verify this by looking for a file that has the .sln type. Use the command prompt above for your operating system.

Open the solution file tree in Visual Studio. If you see multiple projects, you can select which one to run two ways:

  1. Right-clicking on the name of the project and selecting the Run option.
  2. Open the project’s Program.cs file then use the run button in the menu bar.

1.6.5. Check Your Understanding

Question

Which file is the solution?

students-computer:csharp-web-dev-datatypes student$ ls
HelloMethods                      csharp-web-dev-datatypes.sln
TempConverter
  1. TempConverter
  2. HelloMethods
  3. csharp-web-dev-datatypes.sln
  4. Program.cs

Question

Where would Willow find the Program.cs file for the TempConverter project?

students-computer:csharp-web-dev-datatypes student$ ls
HelloMethods                      csharp-web-dev-datatypes.sln
TempConverter
  1. Inside the TempConverter project
  2. Inside the HelloMethods project
  3. Inside the csharp-web-dev-datatypes.sln
  4. None of the above