Repository: ravendb/ravendb
Pull request #20180:  RavenDB-23815 Update install_build_prequisite.sh for Ubuntu 24.04 compatibility
Author: login: Jay-Lokhande
Labels: name: v7.0
Created: 2025-02-19T09:50:09Z | Merged: 2025-03-20T22:43:45Z

### Issue link

https://issues.hibernatingrhinos.com/issue/RavenDB-23815

### Additional description

This PR enhances the RavenDB build environment setup script with improved structure, better compatibility, and streamlined installations. The changes make the script more reliable, easier to maintain, and compatible with newer Ubuntu versions.

Key Changes:
✅ Added an introductory message to display Ubuntu version and codename for better clarity.
✅ Enforced root privileges check using $EUID to prevent issues with script execution.
✅ Expanded supported Ubuntu versions to include 22.04 and 24.04, ensuring wider compatibility.
✅ Replaced which with command -v for better POSIX compliance in command detection.
✅ Simplified Microsoft repository setup by using a dynamic URL, reducing redundant conditionals.
✅ Upgraded .NET SDK installation dynamically from global.json and ensured it initializes correctly.
✅ Added PowerShell installation check to avoid redundant installations.
✅ Improved Node.js installation by using the LTS version from Nodesource, ensuring compatibility.
✅ Ensured Git is installed before proceeding with the build.
✅ Refactored script output messages to provide clear guidance to users during setup.

Testing Done:
✔️ Tested on Ubuntu 20.04, 22.04, and 24.04.
✔️ Verified that .NET, PowerShell, Node.js, and Git install correctly.
✔️ Confirmed script runs smoothly without unnecessary re-installations when dependencies are already installed.

### Type of change

- [x] Bug fix
- [x] Regression bug fix
- [x] Optimization

### How risky is the change?

- [x] Low 

### Backward compatibility

- [x] Non breaking change

### Is it platform specific issue?

- [x] Yes. Please list the affected platforms.

### Documentation update

- [x] No documentation update is needed 

### Testing by Contributor

- [x] It has been verified by manual testing

### Testing by RavenDB QA team

- [x] No special testing by RavenDB QA team is needed

### Is there any existing behavior change of other features due to this change?

- [x] No

### UI work

- [x] No UI work is needed



Diff:
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 07219e74e3e9..6ef491c835d2 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -17,7 +17,7 @@ In order to submit an issue please visit our [YouTrack](https://issues.hibernati
 Recommended dev environment is
 
 - VS 2022 updated to the latest version
-- .NET 6 SDKs
+- .NET SDK version as specified in `global.json`
 - latest NodeJS LTS  
 
 1. Clone this repo, open it in VS 2022.  
@@ -34,7 +34,7 @@ Recommended dev environment is
 
 Preconditions
 
-- .NET 6 SDKs
+- .NET SDK version as specified in `global.json`
 - latest NodeJS LTS 
 - PowerShell (if you are working on Linux, you can find installation instructions [here](https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-linux)) 
 
diff --git a/install_build_prerequisites.sh b/install_build_prerequisites.sh
index e12490ab167d..504f46e1d953 100755
--- a/install_build_prerequisites.sh
+++ b/install_build_prerequisites.sh
@@ -1,101 +1,116 @@
 #!/bin/bash
 
-CURL_CMD=$(which curl)
-GIT_CMD=$(which git)
-NODE_CMD=$(which node)
-POWERSHELL_CMD=$(which pwsh)
-MONO_CMD=$(which mono)
-DOTNET_VERSION_CMD=`dotnet --version 2> /dev/null`
-UBUNTU_CODENAME=$(lsb_release -c | cut -d ":" -f2 | sed 's/\t//g')
-UBUNTU_VERSION=$(lsb_release -r | cut -d ":" -f2 | sed 's/\t//g')
-
-if [[ ! "$UBUNTU_VERSION" =~ ^1[468]\.04$ ]] ; then
-    echo "Unsupported Ubuntu version: $UBUNTU_VERSION $UBUNTU_CODENAME. Must be 20.04, 18.04, 16.04 or 14.04."
-    exit -1
-fi
+# Variable definitions
+UBUNTU_VERSION=$(lsb_release -rs)
+UBUNTU_CODENAME=$(lsb_release -cs)
+
+# Introductory message
+echo "Starting environment setup for RavenDB build on Ubuntu $UBUNTU_VERSION ($UBUNTU_CODENAME)"
 
+# Get the full path of the script
+SCRIPT_PATH=$(realpath "$0")
 
-if [[ $UID != 0 ]]; then
-    echo "Please run this script with sudo:"
-    echo "sudo $0 $*"
+# Check if the script is running with root privileges
+if [ "$EUID" -ne 0 ]; then
+    echo "This script must be run as root. Please use sudo."
+    echo "sudo $SCRIPT_PATH $*"
     exit 1
 fi
 
-eval 
-
-echo "Installing .NET Core SDK 5.0"
+# Check Ubuntu version
+if ! echo "16.04 18.04 20.04 22.04 24.04" | grep -q "$UBUNTU_VERSION"; then
+    echo "Unsupported Ubuntu version: $UBUNTU_VERSION $UBUNTU_CODENAME. Must be 24.04, 22.04, 20.04, 18.04, or 16.04."
+    exit 1
+fi
 
+# Check and install curl
+echo "Checking for curl..."
+CURL_CMD=$(command -v curl)
 if [ -z "$CURL_CMD" ]; then
-    sudo apt-get install -y curl 
+    echo "curl not found. Installing curl..."
+    apt-get install -y curl
+else
+    echo "curl is already installed."
 fi
 
-curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
-
-if [ "$UBUNTU_VERSION" = "16.04" ] ; then
-    sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-xenial-prod xenial main" > /etc/apt/sources.list.d/dotnetdev.list'
-elif [ "$UBUNTU_VERSION" = "14.04" ] ; then
-    sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-trusty-prod trusty main" > /etc/apt/sources.list.d/dotnetdev.list'
-elif [ "$UBUNTU_VERSION" = "18.04" ] ; then
-    sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-bionic-prod bionic main" > /etc/apt/sources.list.d/dotnetdev.list'
-elif [ "$UBUNTU_VERSION" = "20.04" ] ; then
-    sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-focal-prod focal main" > /etc/apt/sources.list.d/dotnetdev.list'          
+# Set up Microsoft repository
+echo "Setting up Microsoft repository for .NET and PowerShell..."
+curl -sSL https://packages.microsoft.com/config/ubuntu/$UBUNTU_VERSION/packages-microsoft-prod.deb -o packages-microsoft-prod.deb
+dpkg -i packages-microsoft-prod.deb
+rm packages-microsoft-prod.deb
+apt-get update
+
+# Check and install jq for parsing JSON
+echo "Checking for jq..."
+JQ_CMD=$(command -v jq)
+if [ -z "$JQ_CMD" ]; then
+    echo "jq not found. Installing jq..."
+    apt-get install -y jq
+else
+    echo "jq is already installed."
 fi
 
-sudo apt-get update
-sudo apt-get install -y dotnet-sdk-5.0
+# Extract .NET SDK version from global.json
+echo "Extracting .NET SDK version from global.json..."
+if [ ! -f "global.json" ]; then
+    echo "Error: global.json not found. Please run this script from the RavenDB repository root directory."
+    exit 1
+fi
 
-mkdir ./dotnet_tmp
-cd ./dotnet_tmp
-sudo dotnet new console
-sudo dotnet build #dotnet telemetry
-cd ..
-sudo rm -rf ./dotnet_tmp
+SDK_VERSION=$(jq -r '.sdk.version' global.json)
+if [ -z "$SDK_VERSION" ] || [ "$SDK_VERSION" == "null" ]; then
+    echo "Error: Failed to parse .NET SDK version from global.json."
+    exit 1
+fi
 
-if [ -z "$POWERSHELL_CMD" ] ; then
-    echo "Powershell not found. Installing.."
+# Derive major.minor version (e.g., 8.0 from 8.0.100)
+MAJOR_MINOR_VERSION=$(echo "$SDK_VERSION" | awk -F. '{print $1"."$2}')
+if [ -z "$MAJOR_MINOR_VERSION" ]; then
+    echo "Error: Unable to determine .NET SDK major.minor version from '$SDK_VERSION'."
+    exit 1
+fi
 
-    if [ -z "$CURL_CMD" ]; then
-        sudo apt-get install -y curl 
-    fi
+# Install .NET SDK
+echo "Installing .NET SDK version $MAJOR_MINOR_VERSION..."
+apt-get install -y dotnet-sdk-$MAJOR_MINOR_VERSION
 
-    if [ "$UBUNTU_VERSION" = "16.04" ] ; then
-        curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list | sudo tee /etc/apt/sources.list.d/microsoft.list
-    elif [ "$UBUNTU_VERSION" = "14.04" ] ; then
-        curl https://packages.microsoft.com/config/ubuntu/14.04/prod.list | sudo tee /etc/apt/sources.list.d/microsoft.list
-    elif [ "$UBUNTU_VERSION" = "18.04" ] ; then
-        curl https://packages.microsoft.com/config/ubuntu/18.04/prod.list | sudo tee /etc/apt/sources.list.d/microsoft.list
-    elif [ "$UBUNTU_VERSION" = "20.04" ] ; then
-        curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list | sudo tee /etc/apt/sources.list.d/microsoft.list                    
-    fi
-    
-    sudo apt-get update
-    sudo apt-get install -y powershell
+# Check and install PowerShell
+echo "Checking for PowerShell..."
+POWERSHELL_CMD=$(command -v pwsh)
+if [ -z "$POWERSHELL_CMD" ]; then
+    echo "PowerShell not found. Installing PowerShell..."
+    apt-get install -y powershell
 else
-    echo "Powershell is installed."
+    echo "PowerShell is already installed."
 fi
 
-if [ -z "$NODE_CMD" ] ; then
-    echo "Node not found. Installing.."
-
-    if [ -z "$CURL_CMD" ]; then
-        sudo apt-get install -y curl 
-    fi
-
-    curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
-    sudo apt-get install -y nodejs build-essential
+# Check and install Node.js
+echo "Checking for Node.js..."
+NODE_CMD=$(command -v node)
+if [ -z "$NODE_CMD" ]; then
+    echo "Node.js not found. Installing Node.js..."
+    curl -sL https://deb.nodesource.com/setup_lts.x | bash -
+    apt-get install -y nodejs build-essential
 else
     NODE_VERSION="$($NODE_CMD --version)"
-
-    if [[ ! "$NODE_VERSION" =~ ^v?(8|9|10|11) ]] ; then
-        echo "Incompatible version of NodeJS found: $NODE_VERSION. NodeJS 8.x or later is required."
+    MAJOR_VERSION=$(echo "$NODE_VERSION" | sed 's/^v\?\([0-9]*\)\..*/\1/')
+    if [ "$MAJOR_VERSION" -lt 8 ]; then
+        echo "Incompatible Node.js version found: $NODE_VERSION. Node.js 8.x or later is required."
         exit 1
     else
-        echo "Node $NODE_VERSION is installed."
+        echo "Node.js $NODE_VERSION is installed and compatible."
     fi
 fi
 
+# Check and install git
+echo "Checking for git..."
+GIT_CMD=$(command -v git)
 if [ -z "$GIT_CMD" ]; then
-    sudo apt-get install -y git
+    echo "git not found. Installing git..."
+    apt-get install -y git
+else
+    echo "git is already installed."
 fi
 
-echo "To build RavenDB run: ./build.sh"
+# Completion message
+echo "Environment setup complete. To build RavenDB run: ./build.sh"


Reviews:
user: login: gregolsky
state: DISMISSED
author_association: MEMBER
submitted_at: 2025-02-27T13:01:52Z
user: login: ayende
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-03-02T10:44:54Z
user: login: ayende
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-03-02T10:50:19Z
user: login: Jay-Lokhande
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-02T10:59:31Z
user: login: ayende
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-03-02T11:14:11Z
user: login: Jay-Lokhande
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-02T12:06:22Z
user: login: ayende
state: APPROVED
author_association: MEMBER
submitted_at: 2025-03-13T18:30:41Z
user: login: gregolsky
state: APPROVED
author_association: MEMBER
submitted_at: 2025-03-20T07:52:15Z

Review comments:
diff_hunk: @@ -9,8 +9,9 @@ DOTNET_VERSION_CMD=`dotnet --version 2> /dev/null`
 UBUNTU_CODENAME=$(lsb_release -c | cut -d ":" -f2 | sed 's/\t//g')
 UBUNTU_VERSION=$(lsb_release -r | cut -d ":" -f2 | sed 's/\t//g')
 
-if [[ ! "$UBUNTU_VERSION" =~ ^1[468]\.04$ ]] ; then
-    echo "Unsupported Ubuntu version: $UBUNTU_VERSION $UBUNTU_CODENAME. Must be 20.04, 18.04, 16.04 or 14.04."
+
+if [[ ! "$UBUNTU_VERSION" =~ ^(16|18|20|22|24)\.04$ ]] ; then
+    echo "Unsupported Ubuntu version: $UBUNTU_VERSION $UBUNTU_CODENAME. Must be 24.04, 20.04, 18.04, or 16.04."
path: install_build_prerequisites.sh
user: login: ayende
body: ```suggestion
    echo "Unsupported Ubuntu version: $UBUNTU_VERSION $UBUNTU_CODENAME. Must be 24.04, 22.04, 20.04, 18.04, or 16.04."
```
created_at: 2025-03-02T08:17:24Z
author_association: MEMBER
diff_hunk: @@ -1,45 +1,43 @@
 #!/bin/bash
 
-CURL_CMD=$(which curl)
-GIT_CMD=$(which git)
-NODE_CMD=$(which node)
-POWERSHELL_CMD=$(which pwsh)
-MONO_CMD=$(which mono)
+CURL_CMD=$(command -v curl)
+GIT_CMD=$(command -v git)
+NODE_CMD=$(command -v node)
+POWERSHELL_CMD=$(command -v pwsh)
+MONO_CMD=$(command -v mono)
 DOTNET_VERSION_CMD=`dotnet --version 2> /dev/null`
 UBUNTU_CODENAME=$(lsb_release -c | cut -d ":" -f2 | sed 's/\t//g')
 UBUNTU_VERSION=$(lsb_release -r | cut -d ":" -f2 | sed 's/\t//g')
 
-if [[ ! "$UBUNTU_VERSION" =~ ^1[468]\.04$ ]] ; then
-    echo "Unsupported Ubuntu version: $UBUNTU_VERSION $UBUNTU_CODENAME. Must be 20.04, 18.04, 16.04 or 14.04."
-    exit -1
-fi
-
+# Introductory message
+echo "Starting environment setup for RavenDB build on Ubuntu $UBUNTU_VERSION ($UBUNTU_CODENAME)"
 
-if [[ $UID != 0 ]]; then
-    echo "Please run this script with sudo:"
-    echo "sudo $0 $*"
path: install_build_prerequisites.sh
user: login: ayende
body: This is important, it means that you can copy/paste the fixed command
created_at: 2025-03-02T10:44:51Z
author_association: MEMBER
diff_hunk: @@ -1,55 +1,52 @@
 #!/bin/bash
 
-CURL_CMD=$(which curl)
-GIT_CMD=$(which git)
-NODE_CMD=$(which node)
-POWERSHELL_CMD=$(which pwsh)
-MONO_CMD=$(which mono)
+CURL_CMD=$(command -v curl)
+GIT_CMD=$(command -v git)
+NODE_CMD=$(command -v node)
+POWERSHELL_CMD=$(command -v pwsh)
+MONO_CMD=$(command -v mono)
 DOTNET_VERSION_CMD=`dotnet --version 2> /dev/null`
 UBUNTU_CODENAME=$(lsb_release -c | cut -d ":" -f2 | sed 's/\t//g')
 UBUNTU_VERSION=$(lsb_release -r | cut -d ":" -f2 | sed 's/\t//g')
 
-if [[ ! "$UBUNTU_VERSION" =~ ^1[468]\.04$ ]] ; then
-    echo "Unsupported Ubuntu version: $UBUNTU_VERSION $UBUNTU_CODENAME. Must be 20.04, 18.04, 16.04 or 14.04."
-    exit -1
-fi
-
+# Introductory message
+echo "Starting environment setup for RavenDB build on Ubuntu $UBUNTU_VERSION ($UBUNTU_CODENAME)"
 
-if [[ $UID != 0 ]]; then
-    echo "Please run this script with sudo:"
-    echo "sudo $0 $*"
+if [ "$EUID" -ne 0 ]; then
+    echo "This script must be run as root. Please use sudo."
     exit 1
 fi
 
-eval 
-
-echo "Installing .NET Core SDK 5.0"
-
-if [ -z "$CURL_CMD" ]; then
-    sudo apt-get install -y curl 
+if ! echo "16.04 18.04 20.04 22.04 24.04" | grep -q "$UBUNTU_VERSION"; then
+    echo "Unsupported Ubuntu version: $UBUNTU_VERSION $UBUNTU_CODENAME. Must be 16.04, 18.04, 20.04, 22.04, or 24.04."
+    exit 1
 fi
 
-curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
-
-if [ "$UBUNTU_VERSION" = "16.04" ] ; then
-    sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-xenial-prod xenial main" > /etc/apt/sources.list.d/dotnetdev.list'
-elif [ "$UBUNTU_VERSION" = "14.04" ] ; then
-    sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-trusty-prod trusty main" > /etc/apt/sources.list.d/dotnetdev.list'
-elif [ "$UBUNTU_VERSION" = "18.04" ] ; then
-    sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-bionic-prod bionic main" > /etc/apt/sources.list.d/dotnetdev.list'
-elif [ "$UBUNTU_VERSION" = "20.04" ] ; then
-    sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-focal-prod focal main" > /etc/apt/sources.list.d/dotnetdev.list'          
+# Check and install curl
+echo "Checking for curl..."
+CURL_CMD=$(command -v curl)
+if [ -z "$CURL_CMD" ]; then
+    echo "curl not found. Installing curl..."
+    apt-get install -y curl
+else
+    echo "curl is already installed."
 fi
 
-sudo apt-get update
-sudo apt-get install -y dotnet-sdk-5.0
-
-mkdir ./dotnet_tmp
-cd ./dotnet_tmp
-sudo dotnet new console
-sudo dotnet build #dotnet telemetry
-cd ..
-sudo rm -rf ./dotnet_tmp
+# Set up Microsoft repository
+echo "Setting up Microsoft repository for .NET and PowerShell..."
+curl -sSL https://packages.microsoft.com/config/ubuntu/$UBUNTU_VERSION/packages-microsoft-prod.deb -o packages-microsoft-prod.deb
+dpkg -i packages-microsoft-prod.deb
+rm packages-microsoft-prod.deb
+apt-get update
+
+# Install .NET SDK
+echo "Installing .NET Core SDK 8.0..."
+apt-get install -y dotnet-sdk-8.0
path: install_build_prerequisites.sh
user: login: ayende
body: Here we should probably consider the `https://github.com/ravendb/ravendb/blob/v7.0/global.json` file - since that changes and we don't want to have to update this script each time
created_at: 2025-03-02T10:49:35Z
author_association: MEMBER
diff_hunk: @@ -1,45 +1,43 @@
 #!/bin/bash
 
-CURL_CMD=$(which curl)
-GIT_CMD=$(which git)
-NODE_CMD=$(which node)
-POWERSHELL_CMD=$(which pwsh)
-MONO_CMD=$(which mono)
+CURL_CMD=$(command -v curl)
+GIT_CMD=$(command -v git)
+NODE_CMD=$(command -v node)
+POWERSHELL_CMD=$(command -v pwsh)
+MONO_CMD=$(command -v mono)
 DOTNET_VERSION_CMD=`dotnet --version 2> /dev/null`
 UBUNTU_CODENAME=$(lsb_release -c | cut -d ":" -f2 | sed 's/\t//g')
 UBUNTU_VERSION=$(lsb_release -r | cut -d ":" -f2 | sed 's/\t//g')
 
-if [[ ! "$UBUNTU_VERSION" =~ ^1[468]\.04$ ]] ; then
-    echo "Unsupported Ubuntu version: $UBUNTU_VERSION $UBUNTU_CODENAME. Must be 20.04, 18.04, 16.04 or 14.04."
-    exit -1
-fi
-
+# Introductory message
+echo "Starting environment setup for RavenDB build on Ubuntu $UBUNTU_VERSION ($UBUNTU_CODENAME)"
 
-if [[ $UID != 0 ]]; then
-    echo "Please run this script with sudo:"
-    echo "sudo $0 $*"
path: install_build_prerequisites.sh
user: login: Jay-Lokhande
body: Hi, I've updated the script to use the EUID check instead of UID. EUID is more reliable in modern environments, especially when running under sudo.  or should we go back to UID.
created_at: 2025-03-02T10:59:31Z
author_association: CONTRIBUTOR
diff_hunk: @@ -1,45 +1,43 @@
 #!/bin/bash
 
-CURL_CMD=$(which curl)
-GIT_CMD=$(which git)
-NODE_CMD=$(which node)
-POWERSHELL_CMD=$(which pwsh)
-MONO_CMD=$(which mono)
+CURL_CMD=$(command -v curl)
+GIT_CMD=$(command -v git)
+NODE_CMD=$(command -v node)
+POWERSHELL_CMD=$(command -v pwsh)
+MONO_CMD=$(command -v mono)
 DOTNET_VERSION_CMD=`dotnet --version 2> /dev/null`
 UBUNTU_CODENAME=$(lsb_release -c | cut -d ":" -f2 | sed 's/\t//g')
 UBUNTU_VERSION=$(lsb_release -r | cut -d ":" -f2 | sed 's/\t//g')
 
-if [[ ! "$UBUNTU_VERSION" =~ ^1[468]\.04$ ]] ; then
-    echo "Unsupported Ubuntu version: $UBUNTU_VERSION $UBUNTU_CODENAME. Must be 20.04, 18.04, 16.04 or 14.04."
-    exit -1
-fi
-
+# Introductory message
+echo "Starting environment setup for RavenDB build on Ubuntu $UBUNTU_VERSION ($UBUNTU_CODENAME)"
 
-if [[ $UID != 0 ]]; then
-    echo "Please run this script with sudo:"
-    echo "sudo $0 $*"
path: install_build_prerequisites.sh
user: login: ayende
body: I meant, the `echo sudo...` line
created_at: 2025-03-02T11:14:11Z
author_association: MEMBER
diff_hunk: @@ -1,55 +1,52 @@
 #!/bin/bash
 
-CURL_CMD=$(which curl)
-GIT_CMD=$(which git)
-NODE_CMD=$(which node)
-POWERSHELL_CMD=$(which pwsh)
-MONO_CMD=$(which mono)
+CURL_CMD=$(command -v curl)
+GIT_CMD=$(command -v git)
+NODE_CMD=$(command -v node)
+POWERSHELL_CMD=$(command -v pwsh)
+MONO_CMD=$(command -v mono)
 DOTNET_VERSION_CMD=`dotnet --version 2> /dev/null`
 UBUNTU_CODENAME=$(lsb_release -c | cut -d ":" -f2 | sed 's/\t//g')
 UBUNTU_VERSION=$(lsb_release -r | cut -d ":" -f2 | sed 's/\t//g')
 
-if [[ ! "$UBUNTU_VERSION" =~ ^1[468]\.04$ ]] ; then
-    echo "Unsupported Ubuntu version: $UBUNTU_VERSION $UBUNTU_CODENAME. Must be 20.04, 18.04, 16.04 or 14.04."
-    exit -1
-fi
-
+# Introductory message
+echo "Starting environment setup for RavenDB build on Ubuntu $UBUNTU_VERSION ($UBUNTU_CODENAME)"
 
-if [[ $UID != 0 ]]; then
-    echo "Please run this script with sudo:"
-    echo "sudo $0 $*"
+if [ "$EUID" -ne 0 ]; then
+    echo "This script must be run as root. Please use sudo."
     exit 1
 fi
 
-eval 
-
-echo "Installing .NET Core SDK 5.0"
-
-if [ -z "$CURL_CMD" ]; then
-    sudo apt-get install -y curl 
+if ! echo "16.04 18.04 20.04 22.04 24.04" | grep -q "$UBUNTU_VERSION"; then
+    echo "Unsupported Ubuntu version: $UBUNTU_VERSION $UBUNTU_CODENAME. Must be 16.04, 18.04, 20.04, 22.04, or 24.04."
+    exit 1
 fi
 
-curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
-
-if [ "$UBUNTU_VERSION" = "16.04" ] ; then
-    sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-xenial-prod xenial main" > /etc/apt/sources.list.d/dotnetdev.list'
-elif [ "$UBUNTU_VERSION" = "14.04" ] ; then
-    sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-trusty-prod trusty main" > /etc/apt/sources.list.d/dotnetdev.list'
-elif [ "$UBUNTU_VERSION" = "18.04" ] ; then
-    sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-bionic-prod bionic main" > /etc/apt/sources.list.d/dotnetdev.list'
-elif [ "$UBUNTU_VERSION" = "20.04" ] ; then
-    sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-focal-prod focal main" > /etc/apt/sources.list.d/dotnetdev.list'          
+# Check and install curl
+echo "Checking for curl..."
+CURL_CMD=$(command -v curl)
+if [ -z "$CURL_CMD" ]; then
+    echo "curl not found. Installing curl..."
+    apt-get install -y curl
+else
+    echo "curl is already installed."
 fi
 
-sudo apt-get update
-sudo apt-get install -y dotnet-sdk-5.0
-
-mkdir ./dotnet_tmp
-cd ./dotnet_tmp
-sudo dotnet new console
-sudo dotnet build #dotnet telemetry
-cd ..
-sudo rm -rf ./dotnet_tmp
+# Set up Microsoft repository
+echo "Setting up Microsoft repository for .NET and PowerShell..."
+curl -sSL https://packages.microsoft.com/config/ubuntu/$UBUNTU_VERSION/packages-microsoft-prod.deb -o packages-microsoft-prod.deb
+dpkg -i packages-microsoft-prod.deb
+rm packages-microsoft-prod.deb
+apt-get update
+
+# Install .NET SDK
+echo "Installing .NET Core SDK 8.0..."
+apt-get install -y dotnet-sdk-8.0
path: install_build_prerequisites.sh
user: login: Jay-Lokhande
body: Got it! I’ve updated the script to read the .NET SDK version directly from global.json, so we don’t have to update it manually anymore. It now extracts the version, picks the right package, and installs it. Also added some error handling in case global.json is missing or incorrect.
created_at: 2025-03-02T12:06:22Z
author_association: CONTRIBUTOR

PR comments:
user: login: ravendb-bot
created_at: 2025-02-27T13:03:01Z
body: Hi!

Thank you for contributing into RavenDB project. Unfortunetely we detected that not all committers signed our CLA.

Following contributors are not in our database:
- Jay Lokhande (91283261+Jay-Lokhande@users.noreply.github.com)

Please visit http://ravendb.net/contributors/cla/sign to sign CLA.

author_association: CONTRIBUTOR
user: login: Jay-Lokhande
created_at: 2025-02-27T14:02:36Z
body: I am working on the remaining issues that has encountered.
author_association: CONTRIBUTOR
user: login: Jay-Lokhande
created_at: 2025-03-02T06:20:48Z
body: The script works on both Ubuntu 24.04 and 22.04, but I’ve only added the configuration for 24.04. Do you think we should add it for 22.04 as well?
author_association: CONTRIBUTOR
user: login: ayende
created_at: 2025-03-02T08:06:59Z
body: It would be best, yes.
author_association: MEMBER
user: login: Jay-Lokhande
created_at: 2025-03-02T14:24:36Z
body: I need to add 'RavenDB-XXXXX:' before each commit message, but I'm not sure what 'XXXXX' should be. Could you please confirm if it refers to an issue number or provide the correct value?
author_association: CONTRIBUTOR
user: login: ayende
created_at: 2025-03-03T09:16:20Z
body: You need to create a new issue here: 
https://issues.hibernatingrhinos.com/issues/RavenDB?

That will give you the actual issue number for the commits
author_association: MEMBER
user: login: Jay-Lokhande
created_at: 2025-03-03T17:37:10Z
body: I have made all the necessary changes. @gregolsky  @ayende , please review them. These changes are running successfully on my system.

author_association: CONTRIBUTOR
user: login: Jay-Lokhande
created_at: 2025-03-05T10:49:22Z
body: Updated the script to automatically download the latest Node.js version if not found. If Node.js is already installed, it now checks whether the version is greater than 8 to determine compatibility. Considering that Node.js 8 is deprecated, should we update the check to require version 18 or 19 instead?
author_association: CONTRIBUTOR
user: login: Jay-Lokhande
created_at: 2025-03-11T15:26:30Z
body: Hey @ayende  @gregolsky ,

I’ve made some updates to the script as suggested by @ayende  and would love to get your feedback on the changes. 
author_association: CONTRIBUTOR
user: login: Jay-Lokhande
created_at: 2025-03-13T09:47:23Z
body: > You need to create a new issue here: https://issues.hibernatingrhinos.com/issues/RavenDB?
> 
> That will give you the actual issue number for the commits

Hello Sir,

Apologies for not acknowledging earlier. I have created the issue as required: [23815] ([Issue Link](https://github.com/ravendb/ravendb/pull/20180#)). I have also made the necessary changes accordingly. Please let me know if any further modifications are needed.

Thank you!
author_association: CONTRIBUTOR
user: login: Jay-Lokhande
created_at: 2025-03-17T10:24:57Z
body: @gregolsky can you please review my pr actually earlier commits messages were not in standard format thats why I changed to new commits messages in required format with issue numbers.
author_association: CONTRIBUTOR
user: login: Jay-Lokhande
created_at: 2025-03-18T11:13:26Z
body: I updated CONTRIBUTING.md to specify the `.NET SDK` version from `global.json` instead of `.NET 6`. Additionally, I think we should mention running `install_build_prerequisite.sh` before` ./build.sh` to ensure all dependencies are installed. Let me know your thoughts!
author_association: CONTRIBUTOR
user: login: ppekrol
created_at: 2025-03-18T11:15:17Z
body: hi @Jay-Lokhande 
we will be looking into your changes this week, were a bit busy lately, thanks!
author_association: MEMBER
user: login: Jay-Lokhande
created_at: 2025-03-18T11:22:50Z
body: > hi @Jay-Lokhande we will be looking into your changes this week, were a bit busy lately, thanks!

Thanks for the update! I appreciate your time and look forward to your feedback.
author_association: CONTRIBUTOR
user: login: Jay-Lokhande
created_at: 2025-03-21T01:03:13Z
body: Hey @ayende @gregolsky @ppekrol @arekpalinski ,
I just wanted to take a moment to sincerely thank you all for your guidance and support throughout my contributions. I truly appreciate the time and effort you’ve put into reviewing my work. Excited to keep collaborating!
author_association: CONTRIBUTOR