dotnet: Rework C# lang version

* use 9.0 for building library
* use 8.0 when building samples
This commit is contained in:
Corentin Le Molgat
2022-11-21 15:15:45 +01:00
parent d2657d29a0
commit 9ffe31dcbf
4 changed files with 13 additions and 10 deletions

View File

@@ -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}")

View File

@@ -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

View File

@@ -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@/<TargetFrameworks>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@/<TargetFrameworks>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@/<TargetFrameworks>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@/<TargetFrameworks>netcoreapp3.1;net6.0<\/TargetFrameworks>/' \
$(TEMP_DOTNET_DIR)$Sortools_examples$Sexamples$Sdotnet$S$$*.csproj

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<LangVersion>8.0</LangVersion>
<LangVersion>@DOTNET_SAMPLE_LANG@</LangVersion>
@DOTNET_TFM@
<EnableDefaultItems>false</EnableDefaultItems>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>