Linux | macOS | Windows |
---|---|---|
Try to build a .NetStandard2.0 native (for win-x64, linux-x64 and osx-x64) nuget multi package using dotnet/cli
and the new .csproj format.
To build the .Net nuget packages, simply run:
cmake -S. -Bbuild -DBUILD_DOTNET=ON
cmake --build build --target dotnet_package -v
note: Since dotnet_package
is in target all
, you can also ommit the
--target
option.
To list tests:
cd build
ctest -N
To only run .NET tests:
cd build
ctest -R "dotnet_.*"
First you should take a look at the ortools/dotnet/README.md to understand the layout.
Here I will only focus on the CMake/SWIG tips and tricks.
Since .Net use a .csproj
project file to orchestrate everything we need to
generate them and have the following layout:
<CMAKE_BINARY_DIR>/dotnet
── Directory.Build.props
├── orLogo.png
├── ortools
│ ├── algorithms
│ │ ├── *.cs
│ │ ├── knapsack_solverCSHARP_wrap.cxx
│ │ ├── operations_research_algorithms.cs
│ │ └── operations_research_algorithmsPINVOKE.cs
│ ├── constraint_solver
│ │ ├── *.cs
│ │ ├── operations_research_constraint_solver.cs
│ │ ├── operations_research_constraint_solverPINVOKE.cs
│ │ ├── routingCSHARP_wrap.cxx
│ │ └── routingCSHARP_wrap.h
│ ├── graph
│ │ ├── *.cs
│ │ ├── graphCSHARP_wrap.cxx
│ │ ├── operations_research_graph.cs
│ │ └── operations_research_graphPINVOKE.cs
│ ├── linear_solver
│ │ ├── *.cs
│ │ ├── LinearSolver.pb.cs
│ │ ├── operations_research_linear_solver.cs
│ │ └── operations_research_linear_solverPINVOKE.cs
│ ├── sat
│ │ ├── *.cs
│ │ ├── BooleanProblem.pb.cs
│ │ ├── CpModel.pb.cs
│ │ ├── SatParameters.pb.cs
│ │ ├── operations_research_sat.cs
│ │ ├── operations_research_satPINVOKE.cs
│ │ ├── satCSHARP_wrap.cxx
│ │ └── satCSHARP_wrap.h
│ └── util
│ ├── *.cs
│ ├── operations_research_utilPINVOKE.cs
│ ├── sorted_interval_listCSHARP_wrap.cxx
│ └── sorted_interval_listCSHARP_wrap.h
├── Google.OrTools.runtime.linux-x64
│ └── Google.OrTools.runtime.linux-x64.csproj
├── Google.OrTools
│ └── Google.OrTools.csproj
├── replace.cmake
└── replace_runtime.cmake
src: tree build/dotnet --prune -I "obj|bin"