From 68cb21838b2e2efb18461f3a27a879f7fa06c157 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Fri, 17 Mar 2023 07:39:59 +0100 Subject: [PATCH 1/4] Encode the .NET version we're targeting in the third NuGet version number. (#17818) Encode the .NET version we're targeting in the third NuGet version number by adding X000 (where X is the .NET version) to the commit distance. This accomplishes a few goals: * We automatically compute a different NuGet version depending on the .NET version we're targeting. * Versions are sorted correctly (.NET 7 nugets have a higher version number than .NET 6 nugets). * It's possible to see which .NET version a NuGet is targeting from the version. The downside is: * The scheme breaks down if we need more than three digits for the commit distance (possible solution: add another zero, so we add X0000 instead of X000). --- Make.config | 23 +++++++++++++++++++---- create-make-config.sh | 4 ---- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/Make.config b/Make.config index 21e58805547e..bbaa8304e585 100644 --- a/Make.config +++ b/Make.config @@ -12,15 +12,31 @@ CURL = curl --fail --location --connect-timeout 15 $(if $(V),--verbose,--silent) # --retry-all-errors: ignore the definition of insanity and retry even for errors that seem like you'd get the same result (such as 404). This isn't the real purpose, because this will also retry errors that will get a different result (such as connection failures / resets), which apparently --retry doesn't cover. CURL_RETRY = $(CURL) --retry 20 --retry-delay 2 --retry-all-errors +DOTNET_TFM=net7.0 +DOTNET_MAJOR_VERSION:=$(firstword $(subst ., ,$(subst net,,$(DOTNET_TFM)))) # calculate commit distance and store it in a file so that we don't have to re-calculate it every time make is executed. # Support for hardcoding a commit distance start offset. -NUGET_VERSION_COMMIT_DISTANCE_START=0 -NUGET_VERSION_STABLE_COMMIT_DISTANCE_START=0 +# +# The default is to add X000, where X is the major .NET version: we need to +# publish different versions of our NuGets for different .NET version +# (example: we need to publish one NuGet with support for Xcode 14.3 for .NET +# 6, and another one for .NET 7) - and these need to have different versions, +# and ordered correctly (the .NET 7 version must have a higher version than +# the .NET 6 version), and ideally it would be possible to just look at the +# version to see which .NET version it's targeting. Adding X000 to the commit +# distance accomplishes all these goals (as long as the commit distance itself +# doesn't need more than 3 digits). +NUGET_VERSION_COMMIT_DISTANCE_START=$(DOTNET_MAJOR_VERSION)000 +NUGET_VERSION_STABLE_COMMIT_DISTANCE_START=$(DOTNET_MAJOR_VERSION)000 -include $(TOP)/Make.config.inc $(TOP)/Make.config.inc: $(TOP)/Make.config $(TOP)/mk/mono.mk - $(Q) cd $(TOP) && ALL_DOTNET_PLATFORMS="$(ALL_DOTNET_PLATFORMS)" ./create-make-config.sh + $(Q) cd $(TOP) && \ + ALL_DOTNET_PLATFORMS="$(ALL_DOTNET_PLATFORMS)" \ + NUGET_VERSION_COMMIT_DISTANCE_START=$(NUGET_VERSION_COMMIT_DISTANCE_START) \ + NUGET_VERSION_STABLE_COMMIT_DISTANCE_START=$(NUGET_VERSION_STABLE_COMMIT_DISTANCE_START) \ + ./create-make-config.sh include $(TOP)/Make.versions @@ -600,7 +616,6 @@ else DOTNET_BCL_VERSION=$(BUNDLED_NETCORE_PLATFORMS_PACKAGE_VERSION) endif -DOTNET_TFM=net7.0 DOTNET_VERSION_BAND=$(firstword $(subst -, ,$(DOTNET_VERSION))) DOTNET_VERSION_PRERELEASE_COMPONENT=$(subst $(DOTNET_VERSION_BAND),,$(DOTNET_VERSION)) DOTNET_INSTALL_NAME=dotnet-sdk-$(DOTNET_VERSION) diff --git a/create-make-config.sh b/create-make-config.sh index 940b9fcf589f..4ed2856c500d 100755 --- a/create-make-config.sh +++ b/create-make-config.sh @@ -11,10 +11,6 @@ rm -f "$OUTPUT_FILE" "$OUTPUT" LANG=C export LANG -# Support for hardcoding a commit distance start offset. -NUGET_VERSION_COMMIT_DISTANCE_START=0 -NUGET_VERSION_STABLE_COMMIT_DISTANCE_START=0 - # Compute commit distances printf "IOS_COMMIT_DISTANCE:=$(git log $(git blame -- ./Make.versions HEAD | grep IOS_PACKAGE_VERSION= | sed 's/ .*//' )..HEAD --oneline | wc -l | sed 's/ //g')\n" >> "$OUTPUT_FILE" printf "MAC_COMMIT_DISTANCE:=$(git log $(git blame -- ./Make.versions HEAD | grep MAC_PACKAGE_VERSION= | sed 's/ .*//' )..HEAD --oneline | wc -l | sed 's/ //g')\n" >> "$OUTPUT_FILE" From 38a24428399530c02535e3d99b9e17d54fb71fe8 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Fri, 17 Mar 2023 07:57:59 +0100 Subject: [PATCH 2/4] [tests] Run the OutOverriddenWithoutOutAttribute test on all platforms on .NET (#17827) --- tests/monotouch-test/ObjCRuntime/RegistrarTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/monotouch-test/ObjCRuntime/RegistrarTest.cs b/tests/monotouch-test/ObjCRuntime/RegistrarTest.cs index b641bab5e7bd..3751e2ffaec0 100644 --- a/tests/monotouch-test/ObjCRuntime/RegistrarTest.cs +++ b/tests/monotouch-test/ObjCRuntime/RegistrarTest.cs @@ -2562,7 +2562,7 @@ public CtorChaining2 (int value) [DllImport ("/usr/lib/libobjc.dylib")] static extern IntPtr class_getInstanceMethod (IntPtr cls, IntPtr sel); -#if !MONOMAC // Registrar_OutExportDerivedClass is from fsharp tests +#if !MONOMAC || NET // Registrar_OutExportDerivedClass is from fsharp tests [Test] public void OutOverriddenWithoutOutAttribute () { From f37c86bd1ed2866a705900630a0c4f28e1eeea2f Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Fri, 17 Mar 2023 07:58:12 +0100 Subject: [PATCH 3/4] [tools] Re-create dotnet-linker.csproj.inc when dotnet-linker.csproj changes. (#17826) --- tools/dotnet-linker/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/dotnet-linker/Makefile b/tools/dotnet-linker/Makefile index 779f13fc4d5e..87b240fac102 100644 --- a/tools/dotnet-linker/Makefile +++ b/tools/dotnet-linker/Makefile @@ -16,7 +16,7 @@ DOTNET_DIRECTORIES += \ # dotnet-linker.csproj.inc contains the dotnet_linker_dependencies variable used to determine if mtouch needs to be rebuilt or not. dotnet-linker.csproj.inc: export BUILD_EXECUTABLE=$(DOTNET) build dotnet-linker.csproj.inc: export BUILD_VERBOSITY=$(DOTNET_BUILD_VERBOSITY) -dotnet-linker.csproj.inc: +dotnet-linker.csproj.inc: dotnet-linker.csproj -include dotnet-linker.csproj.inc $(BUILD_DIR)/dotnet-linker%dll $(BUILD_DIR)/dotnet-linker%pdb: Makefile $(dotnet_linker_dependencies) From 97d1eac9cb204128809473fabb4cc6d3013cf452 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Fri, 17 Mar 2023 11:48:05 +0100 Subject: [PATCH 4/4] [src] Improve the generated project files a little bit. (#17812) * Use the right TFM. * Compute the right assembly name. --- src/Makefile | 1 + src/dotnet.tmpl.csproj | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Makefile b/src/Makefile index 220d96b36921..c33b676f42f5 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1352,6 +1352,7 @@ define DotNetProjectFiles $(DOTNET_BUILD_DIR)/projects/$(1)/$(1).csproj: dotnet.tmpl.csproj Makefile $$(wildcard $(CURDIR)/*.sources) @mkdir -p $$(dir $$@) @sed \ + -e 's*%DOTNET_TFM%*$(DOTNET_TFM)*' \ -e 's*%PLATFORM%*$(1)*' \ -e 's**$$(foreach file,$$($(2)_DOTNET_SOURCES),)*' \ -e 's**$$(foreach file,$$($(2)_DOTNET_APIS),)*' \ diff --git a/src/dotnet.tmpl.csproj b/src/dotnet.tmpl.csproj index b4c63330b1b5..d72b0bc5f096 100644 --- a/src/dotnet.tmpl.csproj +++ b/src/dotnet.tmpl.csproj @@ -3,10 +3,10 @@ <_TargetPlatform>%PLATFORM% - net6.0 + %DOTNET_TFM% .NETCoreApp Library - Xamarin.iOS + Microsoft.%PLATFORM% true ..\..\..\..\..\product.snk latest