Want to Contribute to us or want to have 15k+ Audience read your Article ? Or Just want to make a strong Backlink?

Set up GitHub Codespaces for a .NET 8 application

A couple of days in the past Microsoft launched the brand new model of .NET: .NET 8.
That is the steady model of the newest framework by Microsoft.
If you’re not in a position or unsure to put in the newest .NET model in your native machine, beginning to develop tasks with GitHub Codespaces needs to be an excellent different.

On this article, I’ll present you how one can arrange a GitHub Codespaces for a .NET 8 software. We’ll see:

  • Create a GitHub Codespace to your .NET 8 venture
  • Set up the .NET 8 SDK and runtime in your GitHub Codespace
  • Write and run a easy Blazor app in your GitHub Codespace
  • Use Visible Studio Code options and extensions to reinforce your growth expertise in your GitHub Codespace

Let’s get began!

Construct a container for a .NET 8 venture

Create a default Codespace for the repo

Navigate to your repo and from the “Code” button, choose “Codespaces” after which “Create Codespace on the principle”

Have in mind, every Codespace is relative to the department (by default)

Create a default picture Codespace

When the Codespace is prepared, open the Command Palette with the shortcut Shift+Command+P or Ctrl+Shift+P on Home windows.
Seek for “Codespaces” and select “Add dev container configuration information”.
Select “Create a brand new configuration” after which within the following step, click on on “Present All Definitions”.
Scroll and select “C# (.NET)”.

Image description

Select “7.0-bullseys” or “7.0”.

Image description

Skip the following step by clicking on “Okay”.

Change the devcontainer.json file

After the wizard, GitHub Codespaces, open the brand new devcointainer.json file for you.
That is nice however it’s not for .NET 8 software.
Choose all of the file content material and change with the next devcontainer.json file.

Let’s perceive what’s inside

As you possibly can see, within the options part, there lots of entries:

    "options": {
        "ghcr.io/devcontainers/options/docker-in-docker:2": {},
        "ghcr.io/devcontainers/options/github-cli:1": {
            "model": "2"
        "ghcr.io/devcontainers/options/powershell:1": {
            "model": "newest"
        "ghcr.io/azure/azure-dev/azd:0": {
            "model": "newest"
        "ghcr.io/devcontainers/options/common-utils:2": {},
        "ghcr.io/devcontainers/options/dotnet:2": {
            "model": "none",
            "dotnetRuntimeVersions": "7.0",
            "aspNetCoreRuntimeVersions": "7.0"
Enter fullscreen mode

Exit fullscreen mode

This part isn’t necessary however it provides some helpful options in your codespace just like the GitHub CLI, PowerShell (newest model) and different command line instruments for Azure.
If you rebuild the cointaner with the brand new parameters it would take some time as a result of it wants to put in some packages to allow all these options.

Within the VS Code Extensions, as you possibly can see, the devcontainer will add some extensions only for this container and never for your whole tasks or VS Code situations.

        "vscode": {
            "extensions": [
Enter fullscreen mode

Exit fullscreen mode

Crucial extensions listed here are the C# Dev Equipment (you want a Visible Studio License for this one) and C# extension.
They are going to add a greater growth expertise for .NET and C#.

On this explicit container I’ll add a postCreateCommand for restoring packages when the container is launched.
You needn’t launch this command manually everytime otherwise you needn’t wait minutes once you launch the appliance.

"postCreateCommand": "cd ./demo001 && dotnet restore"

“demo001” is the title of venture folder. Change it in accordance your venture title (if in case you have the venture in a subfolder).

My Blazor software working on the port 44380. That is the rationale why within the “ports” part I added the next settings:

    "forwardPorts": [
    "portsAttributes": {
        "44380": {
            "label": "App",
            "onAutoForward": "notify"
Enter fullscreen mode

Exit fullscreen mode

It signifies that by default the port 44380 is forwarded to allow the navigation from the browser, and also you see the title “App” within the Ports part inside Visible Studio Code.
Additionally, you will obtain a notification once you begin the venture and the port turns into energetic.

Rebuild the Container

When every little thing is prepared, it’s essential to rebuild the container from with the brand new settings.
To rebuild the container, open the Command Palette once more and select “Codespaces: Full Rebuild Container”

Image description

After few seconds your Codespace will restart and you’ll be redirected on the loading display screen.
As I point out firstly of the article, it takes some time to rebuild the container (solely the primary time) as a result of GitHub Codespaces must obtain and set up some packages for the options we added within the devcontainer definition.


On this article, you may have discovered how one can arrange a GitHub Codespace for a .NET 8 software. You’ve got seen how straightforward and handy it’s to make use of GitHub Codespaces to code and construct your .NET 8 venture from anyplace. You’ve got additionally explored a few of the Visible Studio Code options and extensions that may improve your growth expertise in your GitHub Codespace. GitHub Codespaces is a robust instrument that may assist you to save time, assets, and problem when engaged on .NET 8 tasks.

I hope you may have loved this text and located it helpful. When you have any questions or suggestions, please depart a remark under. Thanks for studying! 😊.

Dev Dispatch

If you happen to loved this weblog submit and need to be taught extra about C# growth, you is likely to be involved in subscribing to my bi-weekly publication known as Dev Dispatch. By subscribing, you’ll get entry to unique content material, suggestions, and methods, in addition to updates on the newest information and tendencies within the growth world. Additionally, you will be capable to work together with me, and share your suggestions and solutions. To subscribe, merely navigate to https://buttondown.email/kasuken?tag=devto, enter your e-mail deal with and click on on the Subscribe button. You may unsubscribe at any time. Thanks to your assist!

Add a Comment

Your email address will not be published. Required fields are marked *

Want to Contribute to us or want to have 15k+ Audience read your Article ? Or Just want to make a strong Backlink?