diff --git a/.gitignore b/.gitignore
index 8fb2dcfc8f..8eae3fe34c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -74,3 +74,5 @@ build/
cache/
**/.vscode/*
.DS_Store
+
+!tools/netstandard/CreateSigningKey/CreateSigningKey.dll
diff --git a/makefiles/Makefile.csharp.mk b/makefiles/Makefile.csharp.mk
index 9d47402f26..d36365ea56 100755
--- a/makefiles/Makefile.csharp.mk
+++ b/makefiles/Makefile.csharp.mk
@@ -34,7 +34,7 @@ NAMESPACE_ORTOOLS_FZ:=$(BASE_CLR_ORTOOLS_DLL_NAME).Flatzinc
CLR_ORTOOLS_IMPORT_DLL_NAME:=$(CLR_ORTOOLS_DLL_NAME)
NETSTANDARD_ORTOOLS_IMPORT_DLL_NAME:=$(CLR_ORTOOLS_IMPORT_DLL_NAME).Native
NETSTANDARD_OBJ_DIR = $(OBJ_DIR)$Snetstandard
-NETSTANDARD_RUNTIME_IDENTIFIER=win10-x64
+NETSTANDARD_RUNTIME_IDENTIFIER=
# NuGet specification file name
ORTOOLS_NUSPEC_NAME := or-tools.nuspec
@@ -69,10 +69,10 @@ endif
ifeq "$(SYSTEM)" "win"
NETSTANDARD_RUNTIME_IDENTIFIER=win-$(NETPLATFORM)
-else ifeq ($(PLATFORM),LINUX)
- NETSTANDARD_RUNTIME_IDENTIFIER=linux-$(NETPLATFORM)
else ifeq ($(PLATFORM),MACOSX)
- NETSTANDARD_RUNTIME_IDENTIFIER=osx-$(NETPLATFORM)
+ NETSTANDARD_RUNTIME_IDENTIFIER=osx
+else
+ NETSTANDARD_RUNTIME_IDENTIFIER=linux-$(NETPLATFORM)
endif
CSHARPEXE = \
@@ -181,7 +181,7 @@ csharportools: $(BIN_DIR)/$(CLR_ORTOOLS_DLL_NAME)$(DLL) $(BIN_DIR)/$(CLR_PROTOBU
# setup path for dotnet sdk
CANONIC_PATH_TO_DOTNET_SDK = $(subst $(SPACE),$(BACKSLASH_SPACE),$(subst \,/,$(subst \\,/,$(DOTNET_INSTALL_PATH))))
-PATH_TO_DOTNET_EXE = $(CANONIC_PATH_TO_DOTNET_SDK)$Sdotnet.exe
+PATH_TO_DOTNET_EXE = $(CANONIC_PATH_TO_DOTNET_SDK)$Sdotnet
ifeq ($(wildcard $(CANONIC_PATH_TO_DOTNET_SDK)),)
netstandard:
@echo "The dotnet sdk path was not set properly. Check Makefile.local for more information."
@@ -195,7 +195,7 @@ endif
netstandardortools: $(BIN_DIR)/$(NETSTANDARD_ORTOOLS_DLL_NAME)$(DLL) $(BIN_DIR)/$(CLR_PROTOBUF_DLL_NAME)$(DLL)
$(NETSTANDARD_OBJ_DIR)/AssemblyInfo.cs: \
- $(CLR_KEYFILE) \
+ $(NETSTANDARD_CLR_KEYFILE) \
$(GEN_DIR)/com/google/ortools/properties/CommonAssemblyInfo.cs
$(COPY) tools$Scsharp$SAssemblyInfo.cs $(NETSTANDARD_OBJ_DIR)$SAssemblyInfo.cs
ifdef CLR_KEYFILE
@@ -297,6 +297,11 @@ ifdef CLR_KEYFILE
sn -k $(CLR_KEYFILE)
endif
+$(NETSTANDARD_CLR_KEYFILE):
+ifdef CLR_KEYFILE
+ $(PATH_TO_DOTNET_EXE) run tools$Snetstandard$SCreateSigningKey$SCreateSigningKey.dll $(CLR_KEYFILE)
+endif
+
$(BIN_DIR)/$(CLR_ORTOOLS_DLL_NAME)$(DLL): \
$(GEN_DIR)/com/google/ortools/properties/AssemblyInfo.cs \
$(CLR_KEYFILE) \
@@ -337,14 +342,14 @@ else
endif
$(BIN_DIR)/$(NETSTANDARD_ORTOOLS_DLL_NAME)$(DLL): \
- $(BIN_DIR)/$(NETSTANDARD_ORTOOLS_IMPORT_DLL_NAME)$(DLL) \
+ $(BIN_DIR)/$(NETSTANDARD_ORTOOLS_IMPORT_DLL_NAME)$(SWIG_LIB_SUFFIX) \
netstandard_create_obj_dir \
$(NETSTANDARD_OBJ_DIR)/AssemblyInfo.cs
$(PATH_TO_DOTNET_EXE) restore $(NETSTANDARD_OBJ_DIR)$SOrTools.NetCore.csproj
$(PATH_TO_DOTNET_EXE) build $(NETSTANDARD_OBJ_DIR)$SOrTools.NetCore.csproj -f netstandard2.0 -o:$(realpath $(BIN_DIR))$S
- $(PATH_TO_DOTNET_EXE) pack $(NETSTANDARD_OBJ_DIR)$SOrTools.NetCore.csproj -o:$(realpath $(BIN_DIR))$S /p:PackageVersion=$(OR_TOOLS_VERSION);TargetRid=$(NETSTANDARD_RUNTIME_IDENTIFIER)
+ $(PATH_TO_DOTNET_EXE) pack $(NETSTANDARD_OBJ_DIR)$SOrTools.NetCore.csproj -o:$(realpath $(BIN_DIR))$S /p:PackageVersion=$(OR_TOOLS_VERSION)\;TargetRid=$(NETSTANDARD_RUNTIME_IDENTIFIER)\;NativeDllName=$(NETSTANDARD_ORTOOLS_IMPORT_DLL_NAME).$(SWIG_LIB_SUFFIX)
-$(BIN_DIR)/$(NETSTANDARD_ORTOOLS_IMPORT_DLL_NAME)$(DLL): \
+$(BIN_DIR)/$(NETSTANDARD_ORTOOLS_IMPORT_DLL_NAME)$(SWIG_LIB_SUFFIX): \
$(BIN_DIR)/$(CLR_PROTOBUF_DLL_NAME)$(DLL) \
$(OBJ_DIR)/swig/linear_solver_csharp_wrap.$O \
$(OBJ_DIR)/swig/sat_csharp_wrap.$O \
@@ -372,7 +377,7 @@ $(BIN_DIR)/$(NETSTANDARD_ORTOOLS_IMPORT_DLL_NAME)$(DLL): \
$(GEN_DIR)/com/google/ortools/constraintsolver/RoutingEnums.g.cs\
$(GEN_DIR)/com/google/ortools/sat/CpModel.g.cs \
$(OR_TOOLS_LIBS)
- $(DYNAMIC_LD) $(LDOUT)$(BIN_DIR)$S$(LIB_PREFIX)$(NETSTANDARD_ORTOOLS_IMPORT_DLL_NAME).$(SWIG_LIB_SUFFIX) $(OBJ_DIR)/swig/linear_solver_csharp_wrap.$O $(OBJ_DIR)/swig/sat_csharp_wrap.$O $(OBJ_DIR)/swig/constraint_solver_csharp_wrap.$O $(OBJ_DIR)/swig/knapsack_solver_csharp_wrap.$O $(OBJ_DIR)/swig/graph_csharp_wrap.$O $(OR_TOOLS_LNK) $(OR_TOOLS_LD_FLAGS)
+ $(DYNAMIC_LD) $(LDOUT)$(BIN_DIR)$S$(NETSTANDARD_ORTOOLS_IMPORT_DLL_NAME).$(SWIG_LIB_SUFFIX) $(OBJ_DIR)/swig/linear_solver_csharp_wrap.$O $(OBJ_DIR)/swig/sat_csharp_wrap.$O $(OBJ_DIR)/swig/constraint_solver_csharp_wrap.$O $(OBJ_DIR)/swig/knapsack_solver_csharp_wrap.$O $(OBJ_DIR)/swig/graph_csharp_wrap.$O $(OR_TOOLS_LNK) $(OR_TOOLS_LD_FLAGS)
netstandard_create_obj_dir:
$(MKDIR_P) $(NETSTANDARD_OBJ_DIR)
diff --git a/makefiles/Makefile.port.mk b/makefiles/Makefile.port.mk
index 51985c9b1e..ba5e862808 100755
--- a/makefiles/Makefile.port.mk
+++ b/makefiles/Makefile.port.mk
@@ -14,6 +14,13 @@ ifeq ("$(SYSTEM)","unix")
OR_TOOLS_TOP ?= $(shell pwd)
OS = $(shell uname -s)
DETECTED_PYTHON_VERSION = $(shell python -c "from sys import version_info as v; print (str(v[0]) + '.' + str(v[1]))")
+ # Detect the .net core sdk folder
+ DOTNET_INSTALL_PATH = /usr/local/share/dotnet/sdk
+ ifneq ($(wildcard $(DOTNET_INSTALL_PATH)\dotnet.exe),)
+ DOTNET_INSTALL_PATH = \# DOTNET install path not found
+ endif
+
+
ifeq ($(OS),Linux)
PLATFORM = LINUX
CODEPORT = OpSys-Linux
@@ -138,6 +145,12 @@ ifeq ("$(SYSTEM)","win")
endif
endif
+ # Detect the .net core sdk folder
+ DOTNET_INSTALL_PATH = $(ProgramW6432)\dotnet
+ ifneq ($(wildcard $(DOTNET_INSTALL_PATH)\dotnet.exe),)
+ DOTNET_INSTALL_PATH = \# DOTNET install path not found
+ endif
+
# Set common windows variables
# OS Specific
diff --git a/makefiles/Makefile.third_party.unix.mk b/makefiles/Makefile.third_party.unix.mk
index 855fbd7965..36d62e9ac4 100644
--- a/makefiles/Makefile.third_party.unix.mk
+++ b/makefiles/Makefile.third_party.unix.mk
@@ -296,6 +296,7 @@ Makefile.local: makefiles/Makefile.third_party.unix.mk
@echo JDK_DIRECTORY = $(JDK_DIRECTORY)>> Makefile.local
@echo UNIX_PYTHON_VER = $(DETECTED_PYTHON_VERSION)>> Makefile.local
@echo PATH_TO_CSHARP_COMPILER = $(DETECTED_MCS_BINARY)>> Makefile.local
+ @echo DOTNET_INSTALL_PATH = $(DOTNET_INSTALL_PATH)>> Makefile.local
@echo CLR_KEYFILE = bin/or-tools.snk>> Makefile.local
@echo >> Makefile.local
@echo "# Define UNIX_GLPK_DIR to point to a compiled version of GLPK to use it" >> Makefile.local
diff --git a/makefiles/Makefile.third_party.win.mk b/makefiles/Makefile.third_party.win.mk
index d267434e3e..0059de4d25 100644
--- a/makefiles/Makefile.third_party.win.mk
+++ b/makefiles/Makefile.third_party.win.mk
@@ -374,6 +374,7 @@ Makefile.local: makefiles/Makefile.third_party.$(SYSTEM).mk
@echo JDK_DIRECTORY = $(JDK_DIRECTORY)>> Makefile.local
@echo $(SELECTED_PATH_TO_PYTHON)>> Makefile.local
@echo $(SELECTED_CSC_BINARY)>> Makefile.local
+ @echo DOTNET_INSTALL_PATH = $(DOTNET_INSTALL_PATH)>> Makefile.local
@echo # >> Makefile.local
@echo # Define WINDOWS_SCIP_DIR to point to a compiled version of SCIP to use it >> Makefile.local
@echo # i.e.: path\\scip-4.0.0 >> Makefile.local
diff --git a/tools/README.netstandard b/tools/README.netstandard
index dccd4cb5b8..a2e3a55c8f 100644
--- a/tools/README.netstandard
+++ b/tools/README.netstandard
@@ -60,6 +60,25 @@ The project file can be modified in any text editor as well:
* Building
-The build currently does not detect the .NET SDK folder. The DOTNET_INSTALL_PATH variable must be set Makefile.local file in the build root:
+
+To build use the following command:
+
+make netstandard
+
+The .NET Core SDK 2.0 or later must be installed before building. Use the link below to find appropriate
+download for the build platform.
+
+https://github.com/dotnet/core/blob/master/release-notes/download-archives/2.0.0-download.md
+
+Alternatively the command below can be used to install the SDK:
+curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --channel 2.0
+
+The build will attempt to detect the SDK path. If there are any issues please check the
+DOTNET_INSTALL_PATH variable in the Makefile.local file:
DOTNET_INSTALL_PATH=C:\Program Files\dotnet
+
+The dotnet restore command will not update the nuget packages if the version does not change. This
+can cause confusion when testing local builds. Use the command below to clear the package:
+
+dotnet nuget locals all --clear
\ No newline at end of file
diff --git a/tools/netstandard/CreateSigningKey/CreateSigningKey.dll b/tools/netstandard/CreateSigningKey/CreateSigningKey.dll
new file mode 100644
index 0000000000..eee0ca516a
Binary files /dev/null and b/tools/netstandard/CreateSigningKey/CreateSigningKey.dll differ
diff --git a/tools/netstandard/CreateSigningKey/Program.cs b/tools/netstandard/CreateSigningKey/Program.cs
new file mode 100644
index 0000000000..dae4f4291a
--- /dev/null
+++ b/tools/netstandard/CreateSigningKey/Program.cs
@@ -0,0 +1,29 @@
+using System;
+using System.IO;
+using System.Security.Cryptography;
+
+namespace CreateSigningKey
+{
+ class Program
+ {
+ static void Main(string[] args)
+ {
+ args = new[] { "or-tools.snk" };
+ if (args == null || args.Length == 0)
+ {
+ Console.WriteLine("Key filename not specified.");
+ return;
+ }
+
+ File.WriteAllBytes(args[0], GenerateStrongNameKeyPair());
+ }
+
+ public static byte[] GenerateStrongNameKeyPair()
+ {
+ using (var provider = new RSACryptoServiceProvider(1024, new CspParameters() { KeyNumber = 2 }))
+ {
+ return provider.ExportCspBlob(!provider.PublicOnly);
+ }
+ }
+ }
+}
diff --git a/tools/netstandard/OrTools.NetCore.csproj b/tools/netstandard/OrTools.NetCore.csproj
index c761e406aa..a3b296802c 100644
--- a/tools/netstandard/OrTools.NetCore.csproj
+++ b/tools/netstandard/OrTools.NetCore.csproj
@@ -63,8 +63,8 @@
-
- runtimes/$(TargetRid)/native/Google.OrTools.Native.dll
+
+ runtimes/$(TargetRid)/native/$(NativeDllName)
true
diff --git a/tools/netstandard/OrTools.targets b/tools/netstandard/OrTools.targets
index 67e51c9dfe..35dc229e2f 100644
--- a/tools/netstandard/OrTools.targets
+++ b/tools/netstandard/OrTools.targets
@@ -30,18 +30,10 @@
-
+
PreserveNewest
Google.OrTools.Native.so
-
-
- PreserveNewest
- Google.OrTools.Native.so
-
-
-
-
\ No newline at end of file