Skip to content

Latest commit

 

History

History
58 lines (36 loc) · 2.85 KB

File metadata and controls

58 lines (36 loc) · 2.85 KB

Step 1: Getting Started with GitHub Copilot: Setting Up C# Console App

In this lab exercise, you will set up a new C# Console App using GitHub Copilot. This Console App will be enhanced in subsequent steps to build a Music Store application.

  1. Access GitHub Copilot:

    • Open the Chat Window:

      • Click the chat icon in the activity bar or press Control+Command+I (Mac) / Ctrl+Alt+I (Windows/Linux).
    • Start an Inline Chat:

      • Use Ctrl+I (Windows) or Cmd+I (Mac) to start an inline chat directly in the editor.
    • Quick Chat Dropdown:

      • Open the quick chat dropdown by pressing Shift+Command+I (Mac) / Shift+Ctrl+I (Windows/Linux).
  2. Create a New C# Console App:

    • Use Copilot chat to create a new C# Console App.
    • Type the following command to scaffold a new C# Console App. Try below prompt, the @workspace and /new should be automatically highlighted.
    @workspace /new Create a C# console application with project name as MusicStore.csproj and a solution file as MusicStore.sln, outputs an executable file. Use TargetFramework as net8.0.
    

    Tip: GitHub Copilot provides various slash commands to avoid writing complex prompts for common scenarios. The /new command is particularly useful as it creates a new project based on the specified template. In this case, Copilot generates a new C# Console App named "MusicStore". Try also specifying more details in your prompt, like the target framework, project type, etc., to customize the project creation.

    • Click on the Create Workspace button to set up the project. This will create a new folder named "MusicStore" in your current workspace with the C# Console App project files.

    image

    • Inspect the .csproj file and ensure it targets net8.0. You can edit the text directly. Copilot is a great tool to help you write code, but it is not perfect. It is always a good idea to review the code and make sure it meets your requirements.
    <Project Sdk="Microsoft.NET.Sdk">
      <PropertyGroup>
      <OutputType>Exe</OutputType>
      <TargetFramework>net8.0</TargetFramework>
      </PropertyGroup>
    </Project>
  3. Run Your Application:

    • From the terminal, navigate to the "MusicStore" folder (that contains MusicStore.csproj file) and run the following command:

      dotnet run
    • The console app should run successfully and load the console window with the default output.

    Try asking Copilot for instructions on how to run the application using @workspace Chat participant. The @workspace chat participant has context about the code in your workspace and allows you to ask questions or get help related to the code.


Previous - Home | Next - Step 2: Building the Music Store Application