Installing .NET SDK into an OpenAI Codex environment

OpenAI Codex aids GitHub repos in a sandbox. Install .NET using setup scripts since it’s not pre-installed.

Installing .NET SDK into an OpenAI Codex environment

The current stop of the AI Hype Train are autonomous coding agents. The most recent one is OpenAI Codex, which is a cloud-based software engineering agent, that works in the background on your GitHub repositories.

This happens in a sandbox environment container based on Ubuntu, with several tools pre-installed. Unfortunately, .NET is not part of it (there is an issue to track this). With the help of setup scripts, we can install additional software into each environment.

The official apt -y install dotnet-sdk-9.0 package doesn't let us choose a version and does not install the latest version. So I wrote a custom script to install .NET.

# Script to install .NET SDK 9.0 on Ubuntu 24.04 (which is what OpenAI Codex is running on)
# https://learn.microsoft.com/en-us/dotnet/core/install/linux-scripted-manual?WT.mc_id=dotnet-35129-website#scripted-install

DOTNET_VERSION=9.0.204

# Install .NET Dependencies
sudo apt-get update
sudo apt install -y zlib1g ca-certificates libc6 libgcc-s1 libicu74 libssl3 libstdc++6 libunwind8 zlib1g

# Download and run the .NET SDK installer script
wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh
chmod +x ./dotnet-install.sh
./dotnet-install.sh --version $DOTNET_VERSION
rm -f dotnet-install.sh

# Set $PATH
DOTNET_ROOT=$HOME/.dotnet
BASHRC_FILE="/root/.bashrc"
DOTNET_PATH_EXPORT_LINE="export PATH=\"$DOTNET_ROOT:$DOTNET_ROOT/tools:\$PATH\""
echo "$DOTNET_PATH_EXPORT_LINE" >> "$BASHRC_FILE"
export PATH=$DOTNET_ROOT:$DOTNET_ROOT/tools:$PATH

Enjoy watching Codex solve the nastiest issues in your .NET projects


☝️ Advertisement Block: I will buy myself a pizza every time I make enough money with these ads to do so. So please feed a hungry developer and consider disabling your Ad Blocker.