APSIM can be built against two target frameworks - .NET Framework 4.7.2 (which runs on Linux via mono) and .NET Core 3.1. When building the solution, binaries for both target frameworks will be compiled to the bin/ directory.
Install required packages
apt install <PackageName>
The two target frameworks have slightly different sets of dependencies. When building the solution file, binaries are built for both target frameworks by default, so all dependencies will be required. The following packages are required for both .NET Framework and .NET Core builds:
For .NET Framework builds:
Note: this package is no longer available in Ubuntu’s official repositories. It can be built from source, but can also be considered an optional dependency. The user interface will run without it, but some parts will be missing.
Note: this package is no longer available in Ubuntu’s official repositories. If unavailable, run this command from the ApsimX directory:
cp ApsimNG/Assemblies/webkit-sharp.dll Bin/
For .NET Core builds:
To check if a package is already installed, use
dpkg -s <PackageName>
Obtain source code
git clone https://github.com/APSIMInitiative/ApsimX
Copy ApsimX/ApsimNG/Assemblies/Mono.TextEditor.dll.config to ApsimX/Bin/
Build the solution
dotnet build ApsimX.sln
-f switch may be used to build for a specific target framework. E.g.
dotnet build -f netcoreapp3.0 ApsimX.sln
dotnet build -f net472 ApsimX.sln
Attempts to build the .net framework version of apsim can sometimes result in this error:
/usr/share/dotnet/sdk/5.0.202/Microsoft.Common.CurrentVersion.targets(1216,5): error MSB3644: The reference assemblies for .NETFramework,Version=v4.6.1 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks
This can be fixed by setting the FrameworkPathOverride environment variable. E.g.
FrameworkPathOverride=/usr/lib/mono/4.7.2-api/ dotnet build ApsimX.sln
When running apsim:
System.DllNotFoundException: Unable to load shared library 'sqlite3' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: libsqlite3: cannot open shared object file: No such file or directory
This error can occur on Debian (and its derivatives) when the sqlite3 package is installed. This package typically provides a file named
libsqlite3.so.0 or similar, but apsim is looking for
libsqlite3.so. This file is provided by the
libsqlite3-dev package, so installing this package should fix the problem. Otherwise, creating a symlink to
libsqlite3.so should also fix the problem.
When attempting to install apsim from our binary package:
E: Unable to locate package dotnet-runtime-3.1
This package is not included in the official Debian repositories. You will need to follow the instructions on this page to install the package from microsoft’s repositories.