AI-generated Key Takeaways
-
This guide provides instructions for getting started with OR-Tools in .Net on various Linux distributions, including Alpine, Centos, Debian, Fedora, OpenSuse, and Ubuntu.
-
Before starting, you need to have .Net Core SDK version 3.1 or higher installed, and instructions are provided for different Linux distributions.
-
To run the OR-Tools example, you need to download or clone the
dotnet_or-toolsrepository, build the project usingdotnet build -c Release, and then run the binary usingdotnet run -c Release. -
This guide focuses on providing a simple working example and directs you to further resources for a deeper dive into OR-Tools.
Introduction
This guide gets you started with OR-Tools in .Net with a simple working example.
Although these instructions might also work on other Linux variants, we have only tested them on machines meeting the following requirements:
- Alpine Edge 64-bit (x86_64)
- Centos 7 LTS 64-bit (x86_64)
- Debian SID 64-bit (x86_64)
- Debian 11 (bullseye) 64-bit (x86_64)
- Fedora 38 64-bit (x86_64)
- Fedora 37 64-bit (x86_64)
- OpenSuse Leap 64-bit (x86_64)
- Ubuntu 24.10 64-bit (x86_64)
- Ubuntu 22.04 LTS 64-bit (x86_64)
- Ubuntu 20.04 LTS 64-bit (x86_64)
Prerequisites
The following sections describe the prerequisites for installing OR-Tools.
.Net Core SDK >= 3.1
Next, install the .Net Core SDK version 3.1 or higher. To do so, open a terminal window and enter:
Alpine
apk add dotnet6-sdkref: https://learn.microsoft.com/en-us/dotnet/core/install/linux-alpine
Centos
sudo rpm -Uvh https://packages.microsoft.com/config/centos/7/packages-microsoft-prod.rpmsudo yum install -y dotnet-sdk-6.0
Debian
Before you install .NET, run the following commands to add the Microsoft package signing key to your list of trusted keys and add the package repository.
wget https://packages.microsoft.com/config/debian/11/packages-microsoft-prod.deb -O packages-microsoft-prod.debdpkg -i packages-microsoft-prod.debrm packages-microsoft-prod.deb
sudo apt updatesudo apt install -y dotnet-sdk-6.0
Fedora
sudo dnf install -y dotnet-sdk-6.0Fedora
sudo dnf install -y dotnet-sdk-6.0OpenSUSE
Before you install .NET, run the following commands to add the Microsoft package signing key to your list of trusted keys and add the package repository.
sudo zypper install libicusudo rpm --import https://packages.microsoft.com/keys/microsoft.ascwget https://packages.microsoft.com/config/opensuse/15/prod.reposudo mv prod.repo /etc/zypp/repos.d/microsoft-prod.reposudo chown root:root /etc/zypp/repos.d/microsoft-prod.repo
Then you can install the .Net SDK using the following command:
sudo zypper install -y dotnet-sdk-6.0Ubuntu
sudo apt install -y dotnet-sdk-6.0Ubuntu
sudo apt install -y dotnet-sdk-6.0Ubuntu
sudo apt install -y dotnet-sdk-6.0Get the .Net example code
The example code is located in the dotnet_or-tools repository.
Download the repository as a zip file and extract it, or clone the repository:
git clone -b v9.12 --depth 1 https://github.com/or-tools/dotnet_or-toolsChange to the examples directory:
cd dotnet_or-tools
Build the example
From the dotnet_or-tools directory:
Build the project using:
dotnet build -c ReleaseRun the example
From the dotnet_or-tools directory:
Run the binary using:
dotnet run -c ReleaseCongratulations! You've just run an application with OR-Tools, you are ready to get started with OR-Tools.