写一个shell脚本检测有没有安装dotnet8的sdk
#!/bin/bash
# Function to check if dotnet SDK 8 is installed
check_dotnet_sdk_8() {
if command -v dotnet &> /dev/null; then
dotnet_version=$(dotnet --version)
if [[ $dotnet_version == *"8."* ]]; then
echo "dotnet SDK 8 is installed (Version: $dotnet_version)"
return 0
else
echo "dotnet SDK 8 is not installed."
return 1
fi
else
echo "dotnet SDK is not found."
return 1
fi
}
# Check if dotnet SDK 8 is installed
check_dotnet_sdk_8
如果没有安装则安装,如果安装了则跳过,并运行程序
#!/bin/bash
# Function to check if dotnet SDK is installed
check_dotnet_sdk() {
if command -v dotnet &> /dev/null; then
dotnet_version=$(dotnet --version)
echo "dotnet SDK already installed (Version: $dotnet_version)"
return 0
else
echo "dotnet SDK not found."
return 1
fi
}
# Function to install dotnet SDK 8
install_dotnet_sdk() {
echo "Installing dotnet SDK 8..."
# Check OS
case "$(uname -s)" in
Linux*)
wget -q https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
sudo apt-get update
sudo apt-get install -y apt-transport-https
sudo apt-get update
sudo apt-get install -y dotnet-sdk-8.0
rm -f packages-microsoft-prod.deb
;;
Darwin*)
brew install --cask dotnet-sdk
;;
CYGWIN*|MINGW32*|MSYS*)
echo "Windows OS detected. Please download and install dotnet SDK 8 manually from https://dotnet.microsoft.com/download"
;;
*)
echo "Unsupported OS. Please install dotnet SDK 8 manually from https://dotnet.microsoft.com/download"
;;
esac
}
# Check if dotnet SDK is installed
if ! check_dotnet_sdk; then
# Install dotnet SDK if not installed
install_dotnet_sdk
fi
# Run the local file dotnet GTKWinForms.dll
dotnet GTKWinForms.dll