diff --git a/CMakeLists.txt b/CMakeLists.txt index e0a8061974..56441a21f2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -257,6 +257,14 @@ if(BUILD_DOTNET) option(UNIVERSAL_DOTNET_PACKAGE "Build a .Net multi OS Package" OFF) message(STATUS ".Net: Create multiple os package: ${UNIVERSAL_DOTNET_PACKAGE}") + # Language Version + # see: https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/configure-language-version + set(DOTNET_LANG "9.0" CACHE STRING "Specify the C# language version (default \"9.0\")") + message(STATUS ".Net C# language version: ${DOTNET_LANG}") + + set(DOTNET_SAMPLE_LANG "8.0" CACHE STRING "Specify the C# language version for samples (default \"8.0\")") + message(STATUS ".Net C# language version: ${DOTNET_SAMPLE_LANG}") + option(USE_DOTNET_48 "Use .Net Framework 4.8 support" OFF) message(STATUS ".Net: Use .Net Framework 4.8 support: ${USE_DOTNET_48}") diff --git a/cmake/dotnet.cmake b/cmake/dotnet.cmake index 59f7a772e0..99ebb33f71 100644 --- a/cmake/dotnet.cmake +++ b/cmake/dotnet.cmake @@ -68,11 +68,6 @@ message(STATUS ".Net runtime project: ${DOTNET_NATIVE_PROJECT}") set(DOTNET_NATIVE_PROJECT_DIR ${PROJECT_BINARY_DIR}/dotnet/${DOTNET_NATIVE_PROJECT}) message(STATUS ".Net runtime project build path: ${DOTNET_NATIVE_PROJECT_DIR}") -# Language Version -# see: https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/configure-language-version -set(DOTNET_LANG "9.0") -message(STATUS ".Net C# language version: ${DOTNET_LANG}") - # Targeted Framework Moniker # see: https://docs.microsoft.com/en-us/dotnet/standard/frameworks # see: https://learn.microsoft.com/en-us/dotnet/standard/net-standard diff --git a/makefiles/Makefile.dotnet.mk b/makefiles/Makefile.dotnet.mk index 770730cc8a..49a480fb37 100644 --- a/makefiles/Makefile.dotnet.mk +++ b/makefiles/Makefile.dotnet.mk @@ -108,7 +108,7 @@ $(TEMP_DOTNET_DIR)/$1/%/%.csproj: \ $(SED) -e "s/@DOTNET_PACKAGES_DIR@/..\/..\/..\/$(BUILD_DIR)\/dotnet\/packages/" \ ortools$Sdotnet$SSample.csproj.in \ > $(TEMP_DOTNET_DIR)$S$1$S$$*$S$$*.csproj - $(SED) -i -e 's/@DOTNET_LANG@/9.0/' \ + $(SED) -i -e 's/@DOTNET_SAMPLE_LANG@/9.0/' \ $(TEMP_DOTNET_DIR)$S$1$S$$*$S$$*.csproj ifeq ($(USE_DOTNET_6)_$(USE_DOTNET_CORE_31),ON_ON) $(SED) -i -e 's/@DOTNET_TFM@/netcoreapp3.1;net6.0<\/TargetFrameworks>/' \ @@ -180,7 +180,7 @@ $(TEMP_DOTNET_DIR)/$1/%/%.csproj: \ $(SED) -e "s/@DOTNET_PACKAGES_DIR@/..\/..\/..\/$(BUILD_DIR)\/dotnet\/packages/" \ ortools$Sdotnet$SSample.csproj.in \ > $(TEMP_DOTNET_DIR)$S$1$S$$*$S$$*.csproj - $(SED) -i -e 's/@DOTNET_LANG@/9.0/' \ + $(SED) -i -e 's/@DOTNET_SAMPLE_LANG@/9.0/' \ $(TEMP_DOTNET_DIR)$S$1$S$$*$S$$*.csproj ifeq ($(USE_DOTNET_6)_$(USE_DOTNET_CORE_31),ON_ON) $(SED) -i -e 's/@DOTNET_TFM@/netcoreapp3.1;net6.0<\/TargetFrameworks>/' \ @@ -653,7 +653,7 @@ $(TEMP_DOTNET_DIR)/ortools_examples/examples/dotnet/%.csproj: \ $(TEMP_DOTNET_DIR)$Sortools_examples$Sexamples$Sdotnet$S$$*.csproj $(SED) -i -e 's/@DOTNET_PACKAGES_DIR@/./' \ $(TEMP_DOTNET_DIR)$Sortools_examples$Sexamples$Sdotnet$S$$*.csproj - $(SED) -i -e 's/@DOTNET_LANG@/9.0/' \ + $(SED) -i -e 's/@DOTNET_SAMPLE_LANG@/9.0/' \ $(TEMP_DOTNET_DIR)$Sortools_examples$Sexamples$Sdotnet$S$$*.csproj $(SED) -i -e 's/@DOTNET_TFM@/netcoreapp3.1;net6.0<\/TargetFrameworks>/' \ $(TEMP_DOTNET_DIR)$Sortools_examples$Sexamples$Sdotnet$S$$*.csproj @@ -686,7 +686,7 @@ $(TEMP_DOTNET_DIR)/ortools_examples/examples/dotnet/%.csproj: \ $(TEMP_DOTNET_DIR)$Sortools_examples$Sexamples$Sdotnet$S$$*.csproj $(SED) -i -e 's/@DOTNET_PACKAGES_DIR@/./' \ $(TEMP_DOTNET_DIR)$Sortools_examples$Sexamples$Sdotnet$S$$*.csproj - $(SED) -i -e 's/@DOTNET_LANG@/9.0/' \ + $(SED) -i -e 's/@DOTNET_SAMPLE_LANG@/9.0/' \ $(TEMP_DOTNET_DIR)$Sortools_examples$Sexamples$Sdotnet$S$$*.csproj $(SED) -i -e 's/@DOTNET_TFM@/netcoreapp3.1;net6.0<\/TargetFrameworks>/' \ $(TEMP_DOTNET_DIR)$Sortools_examples$Sexamples$Sdotnet$S$$*.csproj diff --git a/ortools/dotnet/Sample.csproj.in b/ortools/dotnet/Sample.csproj.in index d13eae05bc..3d9802fa5c 100644 --- a/ortools/dotnet/Sample.csproj.in +++ b/ortools/dotnet/Sample.csproj.in @@ -1,7 +1,7 @@ Exe - 8.0 + @DOTNET_SAMPLE_LANG@ @DOTNET_TFM@ false false