Created
August 12, 2023 14:36
-
-
Save aisyshk/5b0087c3ab032e2edf89b01119ca1050 to your computer and use it in GitHub Desktop.
.NET Installation Checker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Function to check if .NET Core 5.0 is installed | |
check_dotnet_core() { | |
dotnet_path=$(command -v dotnet) | |
if [ -n "$dotnet_path" ]; then | |
version_output=$(dotnet --list-sdks | grep -oP '7\.\d+\.\d+' | head -1) | |
if [ -n "$version_output" ]; then | |
echo ".NET Core 7.0 (or higher) is already installed. Version: $version_output" | |
return 0 | |
fi | |
fi | |
return 1 | |
} | |
# Check if .NET Core 7.0 is installed | |
if check_dotnet_core; then | |
sleep 3s | |
dotnet TweetScheduler.dll | |
else | |
echo ".NET Core 7.0 is not installed. Installing...." | |
sleep 3s | |
wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb | |
sudo dpkg -i packages-microsoft-prod.deb | |
rm packages-microsoft-prod.deb | |
sudo apt-get update && \ sudo apt-get install -y dotnet-sdk-7.0 | |
sudo apt-get update && \ | |
sudo apt-get install -y aspnetcore-runtime-7.0 | |
sudo apt-get install -y dotnet-runtime-7.0 | |
# Check if .NET Core 7.0 is installed after download finished | |
if check_dotnet_core; then | |
sleep 3s | |
dotnet ProjectName.dll | |
else | |
echo "There was a problem installing .NET Core 7.0" | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment