Skip to content

Commit

Permalink
check specific dotnet version to determine if we need to install dotn…
Browse files Browse the repository at this point in the history
…et 7 (#137)

* check specific dotnet version to determine if we need to install dotnet 7

* use "update" instead of "install"

* update dev shell to use correct shell
  • Loading branch information
robch authored Dec 14, 2023
1 parent 78fcd1d commit 85e20b5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
18 changes: 15 additions & 3 deletions scripts/InstallAzureAICLIDeb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,18 @@ fi

# Check if dotnet 7.0 is installed
if ! command -v dotnet &> /dev/null; then
echo "dotnet is not installed."
dotnet_version=0
else
dotnet_version=$(dotnet --version | cut -d. -f1)
fi

if [ "$dotnet_version" -eq "7" ]; then
dotnet_version=$(dotnet --version)
echo "dotnet $dotnet_version is already installed."
else
echo "Installing dotnet 7.0..."

# Update the package list
sudo apt-get update

Expand Down Expand Up @@ -111,13 +123,13 @@ fi
echo "Installing Azure.AI.CLI..."

if [ "$EUID" -ne 0 ]; then # if we're not root
dotnet tool install --global --add-source . Azure.AI.CLI --version ${AICLI_VERSION}
dotnet tool update --global --add-source . Azure.AI.CLI --version ${AICLI_VERSION}
DOTNET_TOOLS_PATH="$HOME/.dotnet/tools"
elif [ -n "$SUDO_USER" ]; then # if we're root and SUDO_USER is set, run as SUDO_USER
sudo -u $SUDO_USER dotnet tool install --global --add-source . Azure.AI.CLI --version ${AICLI_VERSION}
sudo -u $SUDO_USER dotnet tool update --global --add-source . Azure.AI.CLI --version ${AICLI_VERSION}
DOTNET_TOOLS_PATH="/home/$SUDO_USER/.dotnet/tools"
else # if we're root and SUDO_USER is not set, use /root as the home directory
dotnet tool install --global --add-source . Azure.AI.CLI --version ${AICLI_VERSION}
dotnet tool update --global --add-source . Azure.AI.CLI --version ${AICLI_VERSION}
DOTNET_TOOLS_PATH="/root/.dotnet/tools"
fi

Expand Down
4 changes: 2 additions & 2 deletions src/ai/commands/dev_command.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ private void DoDevShell()
{
DisplayBanner("dev.shell");

var fileName = OS.IsLinux() ? "bash" : "cmd.exe";
var arguments = OS.IsLinux() ? "-li" : "/k PROMPT (ai dev shell) %PROMPT%& title (ai dev shell)";
var fileName = !OS.IsWindows() ? "bash" : "cmd.exe";
var arguments = !OS.IsWindows() ? "-li" : "/k PROMPT (ai dev shell) %PROMPT%& title (ai dev shell)";

Console.WriteLine("Environment populated:\n");

Expand Down

0 comments on commit 85e20b5

Please sign in to comment.