4 Installation¶
In this section we discuss how to install and setup the MOSEK Fusion API for .NET.
Important
Before running this MOSEK interface please make sure that you:
Installed MOSEK correctly. Some operating systems require extra steps. See the Installation guide for instructions and common troubleshooting tips.
Set up a license. See the Licensing guide for instructions.
Compatibility
The Fusion API for .NET is compatible with the Microsoft .NET framework version 4.5 and later and .NETStandard2.0.
4.1 .NET Core¶
The Fusion API for .NET can be installed as a cross-platform 64bit .NET Core package. The NuGet package Mosek.11.0.0.nupkg
is available for download from:
our website https://mosek.com/downloads
the NuGet repository https://www.nuget.org/packages/Mosek/
Follow the instructions for your .NET Core toolchain to install the package from the repository.
4.2 Manual installation¶
Locating files in the MOSEK Optimization Suite
The relevant files of the Fusion API for .NET are organized as reported in Table 4.1.
Relative Path |
Description |
Label |
---|---|---|
|
Libraries |
|
|
Examples |
|
|
Additional data |
|
where
<MSKHOME>
is the folder in which the MOSEK Optimization Suite has been installed,<PLATFORM>
is the actual platform among those supported by the MOSEK, i.e.win64x86
.
Setting up paths
To compile a .NET program using MOSEK the correct path to mosekdotnet.dll
must be provided. For example, using the Microsoft .NET compiler this is done with the command line option
csc /r:"<LIBDIR>\mosekdotnet.dll" lo1.cs
To run applications the system must be able to locate mosekdotnet.dll
, either in the current directory or in the Global Assembly Cache.
4.3 Testing the Installation and Compiling Examples¶
This section describes how to verify that MOSEK has been installed correctly, and how to build and execute the .NET examples distributed with MOSEK.
Compiling and running from the command line
To compile an example, say lo1
, with the Microsoft .NET compiler, open a DOS box with paths for Visual Studio set up (usually in the Start menu, the sub-menu for Visual Studio contains an entry that starts a DOS box with everything set up).
To compile the example lo1.cs
distributed with MOSEK:
Go to the examples directory
<EXDIR>
.To compile the code and produce an executable, type:
csc /r:"<LIBDIR>\mosekdotnet.dll" lo1.cs
or for Visual Basic:
vbc /r:"<LIBDIR>\mosekdotnet.dll" lo1.vb
Copy
mosekdotnet.dll
into the directory wherelo1.exe
was created, and run the program with:lo1
Compiling the examples using nmake
A makefile for use with nmake
, named Makefile
is available in <EXDIR>
. To compile all examples using this makefile use the command
make /f Makefile all
4.4 Other platforms, Mono¶
The library mosekdotnet.dll
may be used from any .NET compatible language such as Visual Basic, Microsoft C# or Microsoft Managed C++ and with Mono and IronPython. Both the examples and the library should also work with Mono on most 32-bit platforms. If the file mosekdotnet.dll
is not included in the MOSEK distribution for your platform, use mosekdotnet.dll
included in the Windows distribution.
Note that the library accesses methods in the native MOSEK library, which is considered unsafe from a .NET point of view. This means that use of the library in certain restricted contexts is not possible — building an ordinary application and running it from a local drive should not be a problem.
4.4.1 MOSEK and .NET Core¶
The MOSEK NuGet package Mosek.11.0.0.nupkg
is a complete cross-platform .NET Core compatible distribution that works on Windows, Linux and OS X. Assuming that the Mosek.11.0.0.nupkg
file has been downloaded in a directory local-nupkgs
, modify the configuration file *.csproj
to add the following entry
<PropertyGroup>
<RestoreSources>$(RestoreSources);local-nupkgs</RestoreSources>
</PropertyGroup>
Now, add the dependency on MOSEK to the project:
dotnet add package Mosek
and the project using MOSEK API can be built:
dotnet build
dotnet run
Installation instructions for different .NET Core compatible environments may vary.