diff --git a/cmake/dotnet.cmake b/cmake/dotnet.cmake index 16cbf47215..a0978c5b2d 100644 --- a/cmake/dotnet.cmake +++ b/cmake/dotnet.cmake @@ -67,6 +67,10 @@ 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}") # see: Platform if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64|arm64)") set(DOTNET_PLATFORM arm64) diff --git a/makefiles/Makefile.dotnet.mk b/makefiles/Makefile.dotnet.mk index 850e54786c..770730cc8a 100644 --- a/makefiles/Makefile.dotnet.mk +++ b/makefiles/Makefile.dotnet.mk @@ -108,6 +108,8 @@ $(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/' \ + $(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>/' \ $(TEMP_DOTNET_DIR)$S$1$S$$*$S$$*.csproj @@ -178,6 +180,8 @@ $(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/' \ + $(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>/' \ $(TEMP_DOTNET_DIR)$S$1$S$$*$S$$*.csproj @@ -245,6 +249,8 @@ $(TEMP_DOTNET_DIR)/$1/%/%.csproj: \ $(SED) -e "s/@DOTNET_PACKAGES_DIR@/..\/..\/..\/$(BUILD_DIR)\/dotnet\/packages/" \ ortools$Sdotnet$STest.csproj.in \ > $(TEMP_DOTNET_DIR)$S$1$S$$*$S$$*.csproj + $(SED) -i -e 's/@DOTNET_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>/' \ $(TEMP_DOTNET_DIR)$S$1$S$$*$S$$*.csproj @@ -646,6 +652,8 @@ $(TEMP_DOTNET_DIR)/ortools_examples/examples/dotnet/%.csproj: \ $(SED) -i -e 's/@PROJECT_VERSION_PATCH@/$(OR_TOOLS_PATCH)/' \ $(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/' \ $(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 @@ -677,6 +685,8 @@ $(TEMP_DOTNET_DIR)/ortools_examples/examples/dotnet/%.csproj: \ $(SED) -i -e 's/@PROJECT_VERSION_PATCH@/$(OR_TOOLS_PATCH)/' \ $(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/' \ $(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/Google.OrTools-full.csproj.in b/ortools/dotnet/Google.OrTools-full.csproj.in index 0273979cd0..9562248be2 100644 --- a/ortools/dotnet/Google.OrTools-full.csproj.in +++ b/ortools/dotnet/Google.OrTools-full.csproj.in @@ -1,7 +1,7 @@ Library - 9.0 + @DOTNET_LANG@ @DOTNET_TFM@ linux-x64;osx-x64;win-x64;linux-arm64;osx-arm64 true diff --git a/ortools/dotnet/Google.OrTools-local.csproj.in b/ortools/dotnet/Google.OrTools-local.csproj.in index b096480696..25c053b7c7 100644 --- a/ortools/dotnet/Google.OrTools-local.csproj.in +++ b/ortools/dotnet/Google.OrTools-local.csproj.in @@ -1,7 +1,7 @@ Library - 9.0 + @DOTNET_LANG@ @DOTNET_TFM@ @RUNTIME_IDENTIFIER@ true diff --git a/ortools/dotnet/Test.csproj.in b/ortools/dotnet/Test.csproj.in index 4385fb72c4..48b486f4c2 100644 --- a/ortools/dotnet/Test.csproj.in +++ b/ortools/dotnet/Test.csproj.in @@ -1,7 +1,7 @@ Exe - 8.0 + @DOTNET_LANG@ @DOTNET_TFM@ false false