CSE 210: Programming with Classes

Learning Activity - Tools and Setup

Overview

In this course, you will be writing code in C# using the Visual Studio Code (VS Code) editor, and compiling with the .NET framework.

You will need to install and the following applications:

Each of these are industry standard, cross-platform, and freely available.

Tools

Install your tools

  1. Git - Download and install Git by following the official Git Installation Instructions

    • Make sure to select your operating system and download the appropriate installer.
    • Windows users: You can select the latest version at the top of the list. (Otherwise, make sure to select a "standalone installer" rather than a "portable" one.)
    • MacOS users: You may already have Git installed because of Xcode or other tools. You can check by opening a Terminal window and typing, git --version . If the terminal displays a version number, then you already have it installed. If you see a "Command not found" error, then you should install it. You may choose any option you like, but the Binary installer is likely the most straightforward.
  2. VS Code - Download and install VS Code by following the official VS Code Installation Instructions
    • If have already installed VS Code in a previous course (such as CSE 110, 111, or WDD 130), you may skip this step.
  3. C# extension for VS Code - Download and install the extension by following the official C# Extension Instructions.
  4. The .NET SDK - Download and install the .NET SDK that you will use to compile and run your programs by following the official The .NET SDK Installation Instructions.
    • Please get the recommended version and ensure it is for your operating system. As of April 2024, this is .NET 8.0.
    • Important: For Windows, you have a choice for the SDK or the Runtime. Make sure to download the SDK.
    • For MacOS: If you have a an M1/M2 processor, you should download the ARM version. If you have an Intel chip, you should download the x64 version.
    • You may see some warnings about specific versions of Visual Studio. You don't need to worry about these warnings, because you will be using VS Code not the regular "Visual Studio."
Windows: Help to find the right download:

If your are using a windows computer, you will want to download the installer that matches your processor. There are versions for x64 (64-bit processors) and x86 (32-bit processors) as well as a different version if you have an ARM processor.

You can check your processor type by clicking Windows > Settings (the gear icon) > System. Then, scroll down on the left sidebar and select About. This page will show you the "System Type".

Mac Troubleshooting Help:

If you are using MacOS and it cannot find dotnet after installing it, it may be that the location where it was installed, is not listed in your path. This StackOverflow page may be helped for you in putting a link to the dotnet executable into a location that is already in your path.

Course Template

There is a project template for this course that contains a starting place for all of the projects you will need for this course. You will download this template once right now using Git, and then you can use this project for all of your work for the remainder of the course.

Git is a tool for downloading and sharing programs and code. You will learn much more about Git in another learning activity. This activity will help you with the very basics of using it to get the course template to verify that you have installed all the tools correctly.

Create your own copy of the template at GitHub

  1. Go to GitHub.com. Sign up for a new account if you do not already have one. Then, sign in.
  2. Go to the project template repository here: https://github.com/byui-cse/cse210-ww-student-template
    1. Click the green "Use this template" button. This will prompt you to create your own copy of this repository. Choose a name that is meaningful for you, for your repository such as cse210-hw or cse210-projects.
    2. Is the page missing the "Use this template" button?

      If you do not see the green button for "Use this template", it may be because you are not signed in. If you are not signed in, you will see a green "Code" button instead of the correct "Use this template" button. Please sign in to see the correct button.

    3. Select public for your repository so that your instructor and graders can access it.
    4. There is only one branch in the template repository, so it doesn't matter if you include all branches or not.
    5. Once you have finished creating your copy of the repository at GitHub, it should take you to that page with an address such as https://github.com/your-username-here/cse210-hw with your username in the address.

Use Git to download your template to your computer

  1. Open VS Code.
  2. If your VS Code opens up to a previous project, instead of the "Get Started" page, select File -> New Window
  3. On the VS Code Get Started page select, "Clone Git Repository".

    • This brings up a box for you to provide the repository URL. This URL is the web page you were on earlier (such as: https://github.com/your-username-here/cse210-hw, but of course, with your username in the URL).
    • You should copy and paste your URL into this box and press the Enter key. This will bring up a file browser for you to select a location on your computer for your local copy of this repository.
  4. In the file browser, select a location on your computer where you would like to store your homework for this course.
  5. Open the cloned repository when prompted (or alternatively, click "Open..." and browse to the location of this new folder.)

Because C# is designed to run larger projects rather than single files, as you work during this course, it is important that you open this folder (for example "cse210-hw"), not a single file.

Run a C# Project

  1. Once the project is open in VS Code, you can select the debug button on the left menu. (This is a play button with a little "bug" icon next to it.)
  2. In the dropdown box at the top of the debug pane, select the "Sandbox Project" and click the green play button next to it to run it.
  3. It should build and run your sandbox project, which displays "Hello Sandbox World!" in the terminal.
Only seeing ".Net Core Launch" in your dropdown box?

It is important to open the exact folder that you created. If you open a folder above it or below it by accident, or if you simply open a file in VS Code, instead of opening your folder, you will not see the correct options in your dropdown box.

This is because the folder that you created above contains instructions that tell VS Code how to run each of the projects.

Video Demo (Optional)

The following video walks through the steps of getting the course template repository.

Direct link: Getting the Project Template (5 minutes)

Summary

You should have completed the following steps to prepare your computer so that you can develop C# programs:

  1. Installed Git
  2. Installed VS Code (if not already installed)
  3. Installed the .NET Framework
  4. Installed the C# Extension for VS Code
  5. Cloned the course template repository
  6. Successfully run a sample C# program.

That's it! Now your development environment is ready for the this course.

Supplemental: Setting up a new C# Project (Optional)

The steps shown above help you get all the projects and repositories you need for this course. But if you would like to set up your own projects for outside projects, this information may be helpful.

You can create a new .NET (C#) project by typing dotnet new console at a command line terminal in an empty folder. Then, you can run the project by typing dotnet run at the terminal.

That is really all there is to it.

However, if you would like to run and debug these programs in VS Code, you will need to set up some configuration files to tell VS Code how to use your program. The following video walks through these steps:

Direct link: Creating new C# Projects in VS Code (7 minutes)

Getting Help

If you were not able to complete any of these steps, then you are not prepared yet. Please reach out for help in MS Teams.