.NET Core 3.1 Runtime Installer (EOL)

3.1.23 · abandoned · verified Fri Apr 17

The `dotnetcore2` Python package serves as a wrapper to programmatically install the .NET Core 3.1 runtime on various operating systems, primarily Linux. It achieves this by executing Microsoft's official `dotnet-install` scripts. This package is specifically designed for applications that have a dependency on the now End-of-Life (EOL) .NET Core 3.1 runtime. Its latest version is 3.1.23, released in 2020, and the project is no longer actively maintained by its author.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to use `dotnetcore2` to install the .NET Core 3.1 runtime into a specified local directory. It then retrieves the path to the installed runtime for subsequent use, such as executing .NET applications.

import os
from dotnetcore2.runtime import install, get_installed_dotnet_root

# Define a directory where .NET Core 3.1 will be installed
install_dir = os.path.join(os.path.dirname(__file__), "dotnet_runtime_31")

print(f"Attempting to install .NET Core 3.1 to: {install_dir}")
try:
    # The 'install' function handles downloading and setting up .NET Core 3.1
    install(install_dir)
    print("Installation initiated. Checking installed root...")

    # Get the actual path to the installed dotnet executable
    dotnet_root = get_installed_dotnet_root(install_dir)
    if dotnet_root:
        print(f".NET Core 3.1.x installed at: {dotnet_root}")
        print(f"You can now access 'dotnet' command at: {os.path.join(dotnet_root, 'dotnet')}")
    else:
        print("Failed to determine .NET Core 3.1 root after installation.")
except Exception as e:
    print(f"An error occurred during installation: {e}")
    print("Please check the console output above for more details from the dotnet-install script.")

view raw JSON →