Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add examples for C# #741

Merged
merged 3 commits into from
Jul 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ ortools/fsharp/**/bin
ortools/fsharp/**/obj
ortools/fsharp/**/packages

examples/dotnet/**/bin
examples/dotnet/**/obj

ortools/dotnet/**/bin
ortools/dotnet/**/obj
ortools/dotnet/**/packages
Expand Down
36 changes: 0 additions & 36 deletions examples/csharp/solution/Properties/AssemblyInfo.cs

This file was deleted.

3 changes: 0 additions & 3 deletions examples/csharp/solution/app.config

This file was deleted.

48 changes: 48 additions & 0 deletions examples/dotnet/OrTools.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26124.0
MinimumVisualStudioVersion = 15.0.26124.0
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "csharp", "csharp\csharp.csproj", "{0899C5EB-2AD1-49C1-9AB3-735E5B81BF56}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "fsharp", "fsharp\fsharp.fsproj", "{B0E80F2F-BDB3-4688-8E27-5678173DC28C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{0899C5EB-2AD1-49C1-9AB3-735E5B81BF56}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0899C5EB-2AD1-49C1-9AB3-735E5B81BF56}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0899C5EB-2AD1-49C1-9AB3-735E5B81BF56}.Debug|x64.ActiveCfg = Debug|x64
{0899C5EB-2AD1-49C1-9AB3-735E5B81BF56}.Debug|x64.Build.0 = Debug|x64
{0899C5EB-2AD1-49C1-9AB3-735E5B81BF56}.Debug|x86.ActiveCfg = Debug|x86
{0899C5EB-2AD1-49C1-9AB3-735E5B81BF56}.Debug|x86.Build.0 = Debug|x86
{0899C5EB-2AD1-49C1-9AB3-735E5B81BF56}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0899C5EB-2AD1-49C1-9AB3-735E5B81BF56}.Release|Any CPU.Build.0 = Release|Any CPU
{0899C5EB-2AD1-49C1-9AB3-735E5B81BF56}.Release|x64.ActiveCfg = Release|x64
{0899C5EB-2AD1-49C1-9AB3-735E5B81BF56}.Release|x64.Build.0 = Release|x64
{0899C5EB-2AD1-49C1-9AB3-735E5B81BF56}.Release|x86.ActiveCfg = Release|x86
{0899C5EB-2AD1-49C1-9AB3-735E5B81BF56}.Release|x86.Build.0 = Release|x86
{B0E80F2F-BDB3-4688-8E27-5678173DC28C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B0E80F2F-BDB3-4688-8E27-5678173DC28C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B0E80F2F-BDB3-4688-8E27-5678173DC28C}.Debug|x64.ActiveCfg = Debug|x64
{B0E80F2F-BDB3-4688-8E27-5678173DC28C}.Debug|x64.Build.0 = Debug|x64
{B0E80F2F-BDB3-4688-8E27-5678173DC28C}.Debug|x86.ActiveCfg = Debug|x86
{B0E80F2F-BDB3-4688-8E27-5678173DC28C}.Debug|x86.Build.0 = Debug|x86
{B0E80F2F-BDB3-4688-8E27-5678173DC28C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B0E80F2F-BDB3-4688-8E27-5678173DC28C}.Release|Any CPU.Build.0 = Release|Any CPU
{B0E80F2F-BDB3-4688-8E27-5678173DC28C}.Release|x64.ActiveCfg = Release|x64
{B0E80F2F-BDB3-4688-8E27-5678173DC28C}.Release|x64.Build.0 = Release|x64
{B0E80F2F-BDB3-4688-8E27-5678173DC28C}.Release|x86.ActiveCfg = Release|x86
{B0E80F2F-BDB3-4688-8E27-5678173DC28C}.Release|x86.Build.0 = Release|x86
EndGlobalSection
EndGlobal
21 changes: 21 additions & 0 deletions examples/dotnet/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Dotnet Core examples

The following examples showcase how to use OrTools. The project solution has examples for both C# and F#.

We recommend that all projects you create target `netcoreapp2.0` as this allows you to compile for various frameworks and keep up-to-date with the latest frameworks.

Wherever you have ortools installed, be sure to reference the `Google.OrTools.dll` from the project file. You will also need to reference the library folder housing native libraries.

### Linux
To reference a particular folder on linux, you can either: explicitly set the **LD_LIBRARY_PATH**; or create a new configuration file with the path of the library folder in `/etc/ld.so.conf.d/` and then run `sudo ldconfig`. The former will set the path on a system level so that you don't have to use the environment.

### MacOS
To reference a particular folder on linux, you can explicitly set the **DYLD_LIBRARY_PATH**

## CSharp/FSharp project examples

By default all the examples are compiled in a console application with the startup object being the **Classname.Main** so that when compiled the entrypoint will be known.

## NetFx/FSharp compiler examples

Should you have another **netfx** you can compile individual file examples. Please see readme in the individual folders for the target language.
34 changes: 34 additions & 0 deletions examples/dotnet/csharp-netfx/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Examples of using or-tools in C#

This file describes how to use the or-tools .NET binary archive in C#

## Execution

Running the examples will involve compiling them, then running them. You can run the following command for your target operating system.

For example you can compile and run `csflow.cs`. This assumes you have the archive library in a folder called `bin`.


### Windows (32 bit)
```
csc /target:exe /out:bin\csflow.exe /platform:x86 /lib:bin /r:Google.OrTools.dll examples\csharp\csflow.cs
bin\csflow.exe
```

### Windows (64 bit)
```
csc /target:exe /out:bin/csflow.exe /platform:x64 /lib:bin /r:Google.OrTools.dll examples\csharp\csflow.cs
bin\csflow.exe
```

### Linux (framework 4.6+ via mono must be installed)
```
mcs /target:exe /out:bin/csflow.exe /platform:anycpu /lib:bin /r:Google.OrTools.dll examples/csharp/csflow.cs
mono bin/csflow.exe
```

### Mac OS X (framework 4.6+ via mono must be installed)
```
mcs /target:exe /out:bin/csflow.exe /platform:anycpu /lib:bin /r:Google.OrTools.dll examples/csharp/csflow.cs
DYLD_FALLBACK_LIBRARY_PATH=lib mono64 bin/csflow.exe
```
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading