From 2f1234cbda594a795ed14fe834aef3814df49157 Mon Sep 17 00:00:00 2001 From: Jonathan Pryor Date: Thu, 3 Feb 2022 16:49:20 -0500 Subject: [PATCH 1/5] [Java.Interop] $(Version) depends on TargetFramework MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Context: 2d5431f765928e5377288d3284ace3c5d871755a Context: 88d6093c506f6b8bfe47ef0045b16f07d771a890 Context: https://github.com/xamarin/java.interop/pull/936 Context: https://github.com/jonpryor/java.interop/commits/jonp-registration-scope Versioning is hard. Way back in 3e6a6232 we tried to use the `GitInfo` NuGet package so that *all* assemblies would have a version number which contained the number of commits since `GitInfo.txt` changed. This turned out to have unanticipated breakage, and was largely reverted in 2d5431f7 for "core" libs like `Java.Interop.dll`. This still presents a problem, though: the *point* to assembly versioning is to prevent accidental breaking of referencing assemblies. If we add a new member to `Java.Interop.dll` but *fail to update the version*, then that *permits* a scenario in which an app/lib depends on the new member, but is built against a version missing that member. This result in runtime exceptions. The whole reason this hasn't been a problem so far is because `Java.Interop.dll` has barely changed in *years*. (Plus, most usage is hidden behind other layers and libs…) However, *I want this to change*: xamarin/java.interop#936 and jonpryor/java.interop/jonp-registration-scope both *add* new public API to `Java.Interop.dll`, and there are other features and optimizations we're considering that would also require API changes. A policy of "no changes" isn't tenable. Thus, the first priority: allow `Java.Interop.dll` built for .NET 6 to have a different `$(Version)` than the one built for .NET Standard 2.0. Fixing this was unexpectedly problematic, as commit 88d6093c: > Update[d] `Java.Interop.BootstrapTasks.csproj` to *no longer* `` > `VersionInfo.targets`, as this causes a circular dependency > (`VersionInfo.targets` uses tasks from > `Java.Interop.BootstrapTasks.dll`). This is fine, as > `Java.Interop.BootstrapTasks.dll` doesn't need to be versioned. `Java.Interop.BootstrapTasks.dll` doesn't need to be versioned, but *other libraries **do***, and this change change meant that `VersionInfo.targets` was *never* used, which in turn meant that e.g. `bin/BuildDebug/Version.props` was never created. Re-introduce `VersionInfo.targets` by "moving" it into `build-tools/VersionInfo/VersionInfo.csproj`, and adding `VersionInfo.csproj` to `Java.Interop.BootstrapTasks.sln`. This allows the `Prepare` target to create `bin/Build$(Configuration)/Version.props`. Next, update `Java.Interop.csproj` so that `$(Version)` is *conditional* on `$(TargetFramework)`. This allows it to continue using version 0.1.0.0 for .NET Standard 2.0, and begin using 6.0.0.* for .NET 6+ builds. Finally -- and most of the "noise" in this commit -- "cleanup and unify" the disparate build systems. `make prepare all` is one world, while `dotnet` is a different and overlapping world. Clean this up: the `dotnet`-based MSBuild environment is now our Source Of Truth, and the `make` targets are updated to rely on the `Prepare` target instead of duplicating most of the logic. While cleaning up `Makefile`, remove other cruft such as the explicit `gcc` calls to build the `NativeTiming` lib (we have a `.csproj` as of 5c756b14; use it!), and rationalize `Java.Runtime.Environment.dll.config` generation. --- GitInfo.txt | 2 +- Makefile | 59 +++---------------- .../Java.Interop.BootstrapTasks.sln | 10 +++- ...eVersionFile.cs => ReplaceFileContents.cs} | 7 ++- build-tools/VersionInfo/VersionInfo.csproj | 23 ++++++++ build-tools/VersionInfo/VersionInfo.targets | 20 +++++++ build-tools/scripts/Prepare.targets | 9 ++- build-tools/scripts/VersionInfo.targets | 29 --------- build-tools/scripts/jdk.mk | 49 --------------- build-tools/scripts/jdk.targets | 22 ------- .../Java.Interop.Export.csproj | 2 +- src/Java.Interop/Java.Interop.csproj | 2 +- src/Java.Interop/Java.Interop.targets | 6 +- .../Java.Runtime.Environment.csproj | 2 + .../Java.Runtime.Environment.targets | 27 +++++++++ 15 files changed, 106 insertions(+), 163 deletions(-) rename build-tools/{Java.Interop.BootstrapTasks => }/Java.Interop.BootstrapTasks.sln (64%) rename build-tools/Java.Interop.BootstrapTasks/Java.Interop.BootstrapTasks/{GenerateVersionFile.cs => ReplaceFileContents.cs} (78%) create mode 100644 build-tools/VersionInfo/VersionInfo.csproj create mode 100644 build-tools/VersionInfo/VersionInfo.targets delete mode 100644 build-tools/scripts/VersionInfo.targets delete mode 100644 build-tools/scripts/jdk.mk delete mode 100644 build-tools/scripts/jdk.targets create mode 100644 src/Java.Runtime.Environment/Java.Runtime.Environment.targets diff --git a/GitInfo.txt b/GitInfo.txt index ceab6e11e..e0ea36fee 100644 --- a/GitInfo.txt +++ b/GitInfo.txt @@ -1 +1 @@ -0.1 \ No newline at end of file +6.0 diff --git a/Makefile b/Makefile index d782e9130..33a7a12ac 100644 --- a/Makefile +++ b/Makefile @@ -12,12 +12,6 @@ NATIVE_EXT = .so DLLMAP_OS_NAME = linux endif -PREPARE_EXTERNAL_FILES = \ - external/xamarin-android-tools/src/Xamarin.Android.Tools.AndroidSdk/Xamarin.Android.Tools.AndroidSdk.csproj - -DEPENDENCIES = \ - bin/Test$(CONFIGURATION)/libNativeTiming$(NATIVE_EXT) - TESTS = \ bin/Test$(CONFIGURATION)/Java.Interop-Tests.dll \ bin/Test$(CONFIGURATION)/Java.Interop.Dynamic-Tests.dll \ @@ -38,9 +32,10 @@ PTESTS = \ ATESTS = \ bin/Test$(CONFIGURATION)/Android.Interop-Tests.dll -BUILD_PROPS = bin/Build$(CONFIGURATION)/JdkInfo.props bin/Build$(CONFIGURATION)/MonoInfo.props +BUILD_PROPS = bin/Build$(CONFIGURATION)/MonoInfo.props -all: $(DEPENDENCIES) $(TESTS) +all: + msbuild Java.Interop.sln /p:Configuration=$(CONFIGURATION) run-all-tests: r=0; \ @@ -52,50 +47,19 @@ run-all-tests: include build-tools/scripts/msbuild.mk -prepare:: $(BUILD_PROPS) src/Java.Runtime.Environment/Java.Runtime.Environment.dll.config - -prepare:: prepare-bootstrap - $(MSBUILD) $(MSBUILD_FLAGS) /t:Restore Java.Interop.sln - -prepare-bootstrap: prepare-external bin/Build$(CONFIGURATION)/Java.Interop.BootstrapTasks.dll - -bin/Build$(CONFIGURATION)/Java.Interop.BootstrapTasks.dll: build-tools/Java.Interop.BootstrapTasks/Java.Interop.BootstrapTasks.csproj \ - external/xamarin-android-tools/src/Xamarin.Android.Tools.AndroidSdk/Xamarin.Android.Tools.AndroidSdk.csproj \ - $(wildcard build-tools/Java.Interop.BootstrapTasks/Java.Interop.BootstrapTasks/*.cs) - $(MSBUILD) $(MSBUILD_FLAGS) /restore "$<" - -prepare-external $(PREPARE_EXTERNAL_FILES): - git submodule update --init --recursive - (cd external/xamarin-android-tools && $(MAKE) prepare) - nuget restore +prepare:: $(BUILD_PROPS) + dotnet build Java.Interop.sln -c $(CONFIGURATION) -target:Prepare -p:MaxJdkVersion=$(JI_MAX_JDK) -prepare-core: bin/Build$(CONFIGURATION)/MonoInfo.props src/Java.Runtime.Environment/Java.Runtime.Environment.dll.config +prepare-core: bin/Build$(CONFIGURATION)/MonoInfo.props clean: -$(MSBUILD) $(MSBUILD_FLAGS) /t:Clean -rm -Rf bin/$(CONFIGURATION) bin/Build$(CONFIGURATION) bin/Test$(CONFIGURATION) - -rm src/Java.Runtime.Environment/Java.Runtime.Environment.dll.config include build-tools/scripts/mono.mk -include build-tools/scripts/jdk.mk - -JAVA_RUNTIME_ENVIRONMENT_DLLMAP_OVERRIDE = Java.Runtime.Environment.Override.dllmap -ifeq ($(wildcard $(JAVA_RUNTIME_ENVIRONMENT_DLLMAP_OVERRIDE)),) - JAVA_RUNTIME_ENVIRONMENT_DLLMAP_OVERRIDE_CMD = '/@JAVA_RUNTIME_ENVIRONMENT_DLLMAP@/d' -else - JAVA_RUNTIME_ENVIRONMENT_DLLMAP_OVERRIDE_CMD = '/@JAVA_RUNTIME_ENVIRONMENT_DLLMAP@/ {' -e 'r $(JAVA_RUNTIME_ENVIRONMENT_DLLMAP_OVERRIDE)' -e 'd' -e '}' -endif - -src/Java.Runtime.Environment/Java.Runtime.Environment.dll.config: src/Java.Runtime.Environment/Java.Runtime.Environment.dll.config.in \ - bin/Build$(CONFIGURATION)/JdkInfo.props - sed -e 's#@JI_JVM_PATH@#$(JI_JVM_PATH)#g' -e 's#@OS_NAME@#$(DLLMAP_OS_NAME)#g' -e $(JAVA_RUNTIME_ENVIRONMENT_DLLMAP_OVERRIDE_CMD) < $< > $@ +-include bin/Build$(CONFIGURATION)/JdkInfo.mk JAVA_INTEROP_LIB = libjava-interop$(NATIVE_EXT) -NATIVE_TIMING_LIB = libNativeTiming$(NATIVE_EXT) - -bin/Test$(CONFIGURATION)/$(NATIVE_TIMING_LIB): tests/NativeTiming/timing.c $(wildcard $(JI_JDK_INCLUDE_PATHS)/jni.h) - mkdir -p `dirname "$@"` - gcc -g -shared -m64 -fPIC -o $@ $< $(JI_JDK_INCLUDE_PATHS:%=-I%) # Usage: $(call TestAssemblyTemplate,assembly-basename) define TestAssemblyTemplate @@ -109,7 +73,7 @@ $(eval $(call TestAssemblyTemplate,Java.Interop.Dynamic)) $(eval $(call TestAssemblyTemplate,Java.Interop.Export)) $(eval $(call TestAssemblyTemplate,Java.Interop.Tools.JavaCallableWrappers)) -bin/Test$(CONFIGURATION)/Java.Interop-PerformanceTests.dll: $(wildcard tests/Java.Interop-PerformanceTests/*.cs) bin/Test$(CONFIGURATION)/$(NATIVE_TIMING_LIB) +bin/Test$(CONFIGURATION)/Java.Interop-PerformanceTests.dll: $(wildcard tests/Java.Interop-PerformanceTests/*.cs) $(MSBUILD) $(MSBUILD_FLAGS) touch $@ @@ -153,17 +117,12 @@ run-java-source-utils-tests: bin/Test$(CONFIGURATION)/$(JAVA_INTEROP_LIB): bin/$(CONFIGURATION)/$(JAVA_INTEROP_LIB) cp $< $@ -JRE_DLL_CONFIG=bin/$(CONFIGURATION)/Java.Runtime.Environment.dll.config - -$(JRE_DLL_CONFIG): src/Java.Runtime.Environment/Java.Runtime.Environment.csproj - $(MSBUILD) $(MSBUILD_FLAGS) $< - define run-jnimarshalmethod-gen MONO_TRACE_LISTENER=Console.Out \ $(RUNTIME) bin/$(CONFIGURATION)/jnimarshalmethod-gen.exe -v --jvm "$(JI_JVM_PATH)" -L "$(JI_MONO_LIB_PATH)mono/4.5" -L "$(JI_MONO_LIB_PATH)mono/4.5/Facades" $(2) $(1) endef -run-test-jnimarshal: bin/Test$(CONFIGURATION)/Java.Interop.Export-Tests.dll bin/Test$(CONFIGURATION)/$(JAVA_INTEROP_LIB) $(JRE_DLL_CONFIG) +run-test-jnimarshal: bin/Test$(CONFIGURATION)/Java.Interop.Export-Tests.dll bin/Test$(CONFIGURATION)/$(JAVA_INTEROP_LIB) mkdir -p test-jni-output $(call run-jnimarshalmethod-gen,"$<",-f -o test-jni-output --keeptemp) (test -f test-jni-output/$(notdir $<) && test -f test-jni-output/Java.Interop.Export-Tests-JniMarshalMethods.dll) || { echo "jnimarshalmethod-gen did not create the expected assemblies in the test-jni-output directory"; exit 1; } diff --git a/build-tools/Java.Interop.BootstrapTasks/Java.Interop.BootstrapTasks.sln b/build-tools/Java.Interop.BootstrapTasks.sln similarity index 64% rename from build-tools/Java.Interop.BootstrapTasks/Java.Interop.BootstrapTasks.sln rename to build-tools/Java.Interop.BootstrapTasks.sln index 272f06ea5..94b069907 100644 --- a/build-tools/Java.Interop.BootstrapTasks/Java.Interop.BootstrapTasks.sln +++ b/build-tools/Java.Interop.BootstrapTasks.sln @@ -3,9 +3,11 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.1.32104.313 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Java.Interop.BootstrapTasks", "Java.Interop.BootstrapTasks.csproj", "{47C54705-71BA-455D-9F72-780487DE861C}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Java.Interop.BootstrapTasks", "Java.Interop.BootstrapTasks\Java.Interop.BootstrapTasks.csproj", "{47C54705-71BA-455D-9F72-780487DE861C}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Xamarin.Android.Tools.AndroidSdk", "..\..\external\xamarin-android-tools\src\Xamarin.Android.Tools.AndroidSdk\Xamarin.Android.Tools.AndroidSdk.csproj", "{2F8744CF-C265-440A-B976-DEC021324A3E}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Xamarin.Android.Tools.AndroidSdk", "..\external\xamarin-android-tools\src\Xamarin.Android.Tools.AndroidSdk\Xamarin.Android.Tools.AndroidSdk.csproj", "{2F8744CF-C265-440A-B976-DEC021324A3E}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VersionInfo", "VersionInfo\VersionInfo.csproj", "{D5E50EDC-6CE3-4E8D-85A6-6920DF74E44C}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -21,6 +23,10 @@ Global {2F8744CF-C265-440A-B976-DEC021324A3E}.Debug|Any CPU.Build.0 = Debug|Any CPU {2F8744CF-C265-440A-B976-DEC021324A3E}.Release|Any CPU.ActiveCfg = Release|Any CPU {2F8744CF-C265-440A-B976-DEC021324A3E}.Release|Any CPU.Build.0 = Release|Any CPU + {D5E50EDC-6CE3-4E8D-85A6-6920DF74E44C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D5E50EDC-6CE3-4E8D-85A6-6920DF74E44C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D5E50EDC-6CE3-4E8D-85A6-6920DF74E44C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D5E50EDC-6CE3-4E8D-85A6-6920DF74E44C}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/build-tools/Java.Interop.BootstrapTasks/Java.Interop.BootstrapTasks/GenerateVersionFile.cs b/build-tools/Java.Interop.BootstrapTasks/Java.Interop.BootstrapTasks/ReplaceFileContents.cs similarity index 78% rename from build-tools/Java.Interop.BootstrapTasks/Java.Interop.BootstrapTasks/GenerateVersionFile.cs rename to build-tools/Java.Interop.BootstrapTasks/Java.Interop.BootstrapTasks/ReplaceFileContents.cs index c6e8503f2..5ded4e40b 100644 --- a/build-tools/Java.Interop.BootstrapTasks/Java.Interop.BootstrapTasks/GenerateVersionFile.cs +++ b/build-tools/Java.Interop.BootstrapTasks/Java.Interop.BootstrapTasks/ReplaceFileContents.cs @@ -7,15 +7,16 @@ namespace Java.Interop.BootstrapTasks { - public class GenerateVersionFile : Task + public class ReplaceFileContents : Task { - public ITaskItem InputFile { get; set; } + public ITaskItem TemplateFile { get; set; } public ITaskItem OutputFile { get; set; } public ITaskItem [] Replacements { get; set; } + public override bool Execute () { - string text = File.ReadAllText (InputFile.ItemSpec); + string text = File.ReadAllText (TemplateFile.ItemSpec); foreach (var replacement in Replacements) { text = text.Replace (replacement.ItemSpec, replacement.GetMetadata ("Replacement")); diff --git a/build-tools/VersionInfo/VersionInfo.csproj b/build-tools/VersionInfo/VersionInfo.csproj new file mode 100644 index 000000000..a12f8d974 --- /dev/null +++ b/build-tools/VersionInfo/VersionInfo.csproj @@ -0,0 +1,23 @@ + + + + Exe + netstandard2.0 + main + false + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/build-tools/VersionInfo/VersionInfo.targets b/build-tools/VersionInfo/VersionInfo.targets new file mode 100644 index 000000000..8cd13a514 --- /dev/null +++ b/build-tools/VersionInfo/VersionInfo.targets @@ -0,0 +1,20 @@ + + + + + + + + + + + + diff --git a/build-tools/scripts/Prepare.targets b/build-tools/scripts/Prepare.targets index 411f954dc..6ef3b0ae4 100644 --- a/build-tools/scripts/Prepare.targets +++ b/build-tools/scripts/Prepare.targets @@ -6,16 +6,21 @@ - - <_MaxJdk>$(MaxJdkVersion) <_MaxJdk Condition=" '$(_MaxJdk)' == '' ">$(JI_MAX_JDK) $(JAVA_HOME_8_X64) + /Library/Java/JavaVirtualMachines + /usr/lib/jvm + $(JAVA_HOME_11_X64) + /Library/Java/JavaVirtualMachines + /usr/lib/jvm - - - - - main - false - - - - - - - - - - - - - - \ No newline at end of file diff --git a/build-tools/scripts/jdk.mk b/build-tools/scripts/jdk.mk deleted file mode 100644 index 74ea11577..000000000 --- a/build-tools/scripts/jdk.mk +++ /dev/null @@ -1,49 +0,0 @@ -# -# JDK Path Probing -# -# Inputs: -# -# $(OS): Optional; **uname**(1) value of the host operating system -# $(CONFIGURATION): Build configuration name, e.g. Debug or Release -# $(RUNTIME): `mono` executable for the host operating system -# $(JI_MAX_JDK): -# Maximum allowed JDK version, blank by default. -# `xamarin-android` will need to specify 8 here -# -# Outputs: -# -# bin/Build$(CONFIGURATION)/JdkInfo.props: -# MSBuild property file which contains a @(JdkIncludePath) MSBuild -# ItemGroup which contains the $(JI_JDK_INCLUDE_PATHS) values, and -# a $(JdkJvmPath) MSBuild Property which contains $(JI_JVM_PATH). -# $(JI_JDK_INCLUDE_PATHS): -# One or more space separated paths which contain directories to pass as -# -Ipath values to the compiler. -# It DOES NOT contain the -I itself; use $(JI_JDK_INCLUDE_PATHS:%=-I%) for that. -# $(JI_JVM_PATH): -# Location of the Java native library that contains e.g. JNI_CreateJavaVM(). -# $(JI_JDK_BIN_PATH): -# Location of the JDK `/bin` directory, which contains `java/`javac`/etc. - -OS ?= $(shell uname) - -_INCLUDE_MK = bin/Build$(CONFIGURATION)/JdkInfo.mk -_INCLUDE_PROPS = bin/Build$(CONFIGURATION)/JdkInfo.props - -prepare:: $(_INCLUDE_MK) - --include $(_INCLUDE_MK) - -ifeq ($(OS),Darwin) -_JDKS_ROOT := /Library/Java/JavaVirtualMachines -endif # $(OS)=Darwin - -ifeq ($(OS),Linux) -_JDKS_ROOT := /usr/lib/jvm -endif # $(OS)=Linux - -$(_INCLUDE_MK) $(_INCLUDE_PROPS): bin/Build$(CONFIGURATION)/Java.Interop.BootstrapTasks.dll - $(MSBUILD) $(MSBUILD_FLAGS) build-tools/scripts/jdk.targets /t:GetPreferredJdkRoot \ - /p:JdksRoot="$(_JDKS_ROOT)" \ - /p:DotnetToolPath="$(DOTNET_TOOL_PATH)" \ - $(if $(JI_MAX_JDK),"/p:MaximumJdkVersion=$(JI_MAX_JDK)") diff --git a/build-tools/scripts/jdk.targets b/build-tools/scripts/jdk.targets deleted file mode 100644 index b1a750995..000000000 --- a/build-tools/scripts/jdk.targets +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - diff --git a/src/Java.Interop.Export/Java.Interop.Export.csproj b/src/Java.Interop.Export/Java.Interop.Export.csproj index bc3170252..da0c2aef9 100644 --- a/src/Java.Interop.Export/Java.Interop.Export.csproj +++ b/src/Java.Interop.Export/Java.Interop.Export.csproj @@ -7,7 +7,7 @@ true ..\..\product.snk Java.Interop.Export - 0.1.0.0 + 0.1.0.0 $(ToolOutputFullPath) diff --git a/src/Java.Interop/Java.Interop.csproj b/src/Java.Interop/Java.Interop.csproj index 1ee9e3c10..2e63ac2ec 100644 --- a/src/Java.Interop/Java.Interop.csproj +++ b/src/Java.Interop/Java.Interop.csproj @@ -30,7 +30,7 @@ enable true NU1702 - 0.1.0.0 + 0.1.0.0 DEBUG;$(DefineConstants) diff --git a/src/Java.Interop/Java.Interop.targets b/src/Java.Interop/Java.Interop.targets index c5bd6af31..140fe293b 100644 --- a/src/Java.Interop/Java.Interop.targets +++ b/src/Java.Interop/Java.Interop.targets @@ -31,7 +31,7 @@ - + @@ -41,8 +41,8 @@ - diff --git a/src/Java.Runtime.Environment/Java.Runtime.Environment.csproj b/src/Java.Runtime.Environment/Java.Runtime.Environment.csproj index 079fee8f8..264005096 100644 --- a/src/Java.Runtime.Environment/Java.Runtime.Environment.csproj +++ b/src/Java.Runtime.Environment/Java.Runtime.Environment.csproj @@ -19,6 +19,8 @@ + + PreserveNewest diff --git a/src/Java.Runtime.Environment/Java.Runtime.Environment.targets b/src/Java.Runtime.Environment/Java.Runtime.Environment.targets new file mode 100644 index 000000000..588393e26 --- /dev/null +++ b/src/Java.Runtime.Environment/Java.Runtime.Environment.targets @@ -0,0 +1,27 @@ + + + + + + + <_OverrideFile>$(MSBuildThisFileDirectory)../../Java.Runtime.Environment.Override.dllmap + + + + + + + + + + + From d88053181ff5b44dfd2a0a4d1be79386ea3d8b47 Mon Sep 17 00:00:00 2001 From: Jonathan Pryor Date: Thu, 3 Feb 2022 21:58:05 -0500 Subject: [PATCH 2/5] Debug build failure? MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The **Windows - .NET Core** > **Prepare Solution** step is failing: ##[error]build-tools\VersionInfo\VersionInfo.csproj(0,0): Error MSB4236: The SDK 'Microsoft.Build.NoTargets' specified could not be found. D:\a\1\s\build-tools\VersionInfo\VersionInfo.csproj : error MSB4236: The SDK 'Microsoft.Build.NoTargets' specified could not be found. …which doesn't make sense, as `Microsoft.Build.NoTargets` is versioned in `global.json`, and similar usage works in xamarin-android… Hypothesis: it works elsewhere because the `.sln` is in the same dir as the `global.json`, which isn't the case here. Theory: adding `build-tools/global.json` will fix things. Time to test! Result: it worked. Thus, final fix: move `Java.Interop.BootstrapTasks.sln` into topdir, allowing us to remove `build-tools/global.json`. Other cleanups done as well. --- GitInfo.txt | 2 +- ...Tasks.sln => Java.Interop.BootstrapTasks.sln | 6 +++--- Makefile | 4 ++-- .../Java.Interop.BootstrapTasks/JdkInfo.cs | 10 +++++----- build-tools/VersionInfo/VersionInfo.csproj | 3 --- build-tools/VersionInfo/VersionInfo.targets | 9 ++++++--- build-tools/scripts/Prepare.targets | 17 ++++++----------- build-tools/scripts/Version.props.in | 11 +++++++++-- build-tools/scripts/msbuild.mk | 6 +++--- 9 files changed, 35 insertions(+), 33 deletions(-) rename build-tools/Java.Interop.BootstrapTasks.sln => Java.Interop.BootstrapTasks.sln (82%) diff --git a/GitInfo.txt b/GitInfo.txt index e0ea36fee..eb0e103f5 100644 --- a/GitInfo.txt +++ b/GitInfo.txt @@ -1 +1 @@ -6.0 +6.0.200 diff --git a/build-tools/Java.Interop.BootstrapTasks.sln b/Java.Interop.BootstrapTasks.sln similarity index 82% rename from build-tools/Java.Interop.BootstrapTasks.sln rename to Java.Interop.BootstrapTasks.sln index 94b069907..7c7940742 100644 --- a/build-tools/Java.Interop.BootstrapTasks.sln +++ b/Java.Interop.BootstrapTasks.sln @@ -3,11 +3,11 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.1.32104.313 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Java.Interop.BootstrapTasks", "Java.Interop.BootstrapTasks\Java.Interop.BootstrapTasks.csproj", "{47C54705-71BA-455D-9F72-780487DE861C}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Java.Interop.BootstrapTasks", "build-tools\Java.Interop.BootstrapTasks\Java.Interop.BootstrapTasks.csproj", "{47C54705-71BA-455D-9F72-780487DE861C}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Xamarin.Android.Tools.AndroidSdk", "..\external\xamarin-android-tools\src\Xamarin.Android.Tools.AndroidSdk\Xamarin.Android.Tools.AndroidSdk.csproj", "{2F8744CF-C265-440A-B976-DEC021324A3E}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Xamarin.Android.Tools.AndroidSdk", "external\xamarin-android-tools\src\Xamarin.Android.Tools.AndroidSdk\Xamarin.Android.Tools.AndroidSdk.csproj", "{2F8744CF-C265-440A-B976-DEC021324A3E}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VersionInfo", "VersionInfo\VersionInfo.csproj", "{D5E50EDC-6CE3-4E8D-85A6-6920DF74E44C}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VersionInfo", "build-tools\VersionInfo\VersionInfo.csproj", "{D5E50EDC-6CE3-4E8D-85A6-6920DF74E44C}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/Makefile b/Makefile index 33a7a12ac..36e9da734 100644 --- a/Makefile +++ b/Makefile @@ -35,7 +35,7 @@ ATESTS = \ BUILD_PROPS = bin/Build$(CONFIGURATION)/MonoInfo.props all: - msbuild Java.Interop.sln /p:Configuration=$(CONFIGURATION) + $(MSBUILD) $(MSBUILD_FLAGS) Java.Interop.sln run-all-tests: r=0; \ @@ -48,7 +48,7 @@ run-all-tests: include build-tools/scripts/msbuild.mk prepare:: $(BUILD_PROPS) - dotnet build Java.Interop.sln -c $(CONFIGURATION) -target:Prepare -p:MaxJdkVersion=$(JI_MAX_JDK) + $(MSBUILD) $(MSBUILD_FLAGS) Java.Interop.sln -target:Prepare $(if $(JI_MAX_JDK),-p:MaxJdkVersion=$(JI_MAX_JDK),) prepare-core: bin/Build$(CONFIGURATION)/MonoInfo.props diff --git a/build-tools/Java.Interop.BootstrapTasks/Java.Interop.BootstrapTasks/JdkInfo.cs b/build-tools/Java.Interop.BootstrapTasks/Java.Interop.BootstrapTasks/JdkInfo.cs index 4022755b7..95014835e 100644 --- a/build-tools/Java.Interop.BootstrapTasks/Java.Interop.BootstrapTasks/JdkInfo.cs +++ b/build-tools/Java.Interop.BootstrapTasks/Java.Interop.BootstrapTasks/JdkInfo.cs @@ -17,7 +17,7 @@ namespace Java.Interop.BootstrapTasks { public class JdkInfo : Task { - public string JdksRoot { get; set; } + public string JdkRoot { get; set; } public string PropertyNameModifier { get; set; } = ""; public string MinimumJdkVersion { get; set; } @@ -49,7 +49,7 @@ public override bool Execute () .FirstOrDefault (); if (jdk == null) { - Log.LogError ("Could not determine JAVA_HOME location. Please set JdksRoot or export the JAVA_HOME environment variable."); + Log.LogError ($"Could not determine JAVA_HOME location. Please set {nameof(JdkRoot)} or export the JAVA_HOME environment variable."); return false; } @@ -75,10 +75,10 @@ XATInfo[] GetJdkRoots () { XATInfo jdk = null; try { - if (!string.IsNullOrEmpty (JdksRoot)) - jdk = new XATInfo (JdksRoot); + if (!string.IsNullOrEmpty (JdkRoot)) + jdk = new XATInfo (JdkRoot); } catch (Exception e) { - Log.LogWarning ($"Could not get information about JdksRoot path `{JdksRoot}`: {e.Message}"); + Log.LogWarning ($"Could not get information about {nameof (JdkRoot)} path `{JdkRoot}`: {e.Message}"); Log.LogMessage (MessageImportance.Low, e.ToString ()); } return jdk == null diff --git a/build-tools/VersionInfo/VersionInfo.csproj b/build-tools/VersionInfo/VersionInfo.csproj index a12f8d974..4f55f0655 100644 --- a/build-tools/VersionInfo/VersionInfo.csproj +++ b/build-tools/VersionInfo/VersionInfo.csproj @@ -7,9 +7,6 @@ false - - diff --git a/build-tools/VersionInfo/VersionInfo.targets b/build-tools/VersionInfo/VersionInfo.targets index 8cd13a514..711a9234d 100644 --- a/build-tools/VersionInfo/VersionInfo.targets +++ b/build-tools/VersionInfo/VersionInfo.targets @@ -1,4 +1,7 @@ - + + + - + diff --git a/build-tools/scripts/Prepare.targets b/build-tools/scripts/Prepare.targets index 6ef3b0ae4..c878ff2d3 100644 --- a/build-tools/scripts/Prepare.targets +++ b/build-tools/scripts/Prepare.targets @@ -6,24 +6,19 @@ - - <_MaxJdk>$(MaxJdkVersion) <_MaxJdk Condition=" '$(_MaxJdk)' == '' ">$(JI_MAX_JDK) - $(JAVA_HOME_8_X64) - /Library/Java/JavaVirtualMachines - /usr/lib/jvm - $(JAVA_HOME_11_X64) - /Library/Java/JavaVirtualMachines - /usr/lib/jvm + $(JAVA_HOME_8_X64) - $(JAVA_HOME_11_X64) + $(JAVA_HOME_11_X64) @VERSION@ - @VERSION@ git-rev-head:@COMMIT@ git-branch:@BRANCH@ Microsoft Corporation Microsoft Corporation - \ No newline at end of file + + + + $(Version) git-rev-head:@COMMIT@ git-branch:@BRANCH@ + + + + diff --git a/build-tools/scripts/msbuild.mk b/build-tools/scripts/msbuild.mk index 5819b01ed..281febc86 100644 --- a/build-tools/scripts/msbuild.mk +++ b/build-tools/scripts/msbuild.mk @@ -21,9 +21,9 @@ # $(MSBUILD): The MSBuild program to use. Defaults to `xbuild` unless overridden. # $(MSBUILD_FLAGS): Additional MSBuild flags; contains $(CONFIGURATION), $(V), $(MSBUILD_ARGS). -MSBUILD = msbuild -MSBUILD_FLAGS = /p:Configuration=$(CONFIGURATION) $(MSBUILD_ARGS) +MSBUILD = dotnet build +MSBUILD_FLAGS = -c $(CONFIGURATION) $(MSBUILD_ARGS) ifneq ($(V),0) -MSBUILD_FLAGS += /v:d +MSBUILD_FLAGS += -v:diag endif # $(V) != 0 From 9784d41d042fee743e9579e32af7aff69da4d3d2 Mon Sep 17 00:00:00 2001 From: Jonathan Pryor Date: Fri, 4 Feb 2022 15:26:54 -0500 Subject: [PATCH 3/5] Fixity Fix --- build-tools/VersionInfo/VersionInfo.csproj | 2 +- build-tools/scripts/RunNUnitTests.targets | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build-tools/VersionInfo/VersionInfo.csproj b/build-tools/VersionInfo/VersionInfo.csproj index 4f55f0655..8da273023 100644 --- a/build-tools/VersionInfo/VersionInfo.csproj +++ b/build-tools/VersionInfo/VersionInfo.csproj @@ -1,4 +1,4 @@ - + Exe diff --git a/build-tools/scripts/RunNUnitTests.targets b/build-tools/scripts/RunNUnitTests.targets index c00b6c767..b94bb5bc2 100644 --- a/build-tools/scripts/RunNUnitTests.targets +++ b/build-tools/scripts/RunNUnitTests.targets @@ -5,7 +5,7 @@ <_TopDir>$(MSBuildThisFileDirectory)..\.. <_Runtime Condition=" '$(RUNTIME)' != '' ">$(RUNTIME) <_Runtime Condition=" '$(RUNTIME)' == '' And '$(OS)' != 'Windows_NT' ">mono --debug - <_NUnit>$(_Runtime) packages\nunit.consolerunner\3.12.0\tools\nunit3-console.exe + <_NUnit>$(_Runtime) packages/nunit.consolerunner/3.12.0/tools/nunit3-console.exe <_Run Condition=" '$(RUN)' != '' ">--run="$(RUN)" Date: Fri, 4 Feb 2022 21:03:30 -0500 Subject: [PATCH 4/5] Attempt to fix 9009 error on Windows: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit RunTests: packages/nunit.consolerunner/3.12.0/tools/nunit3-console.exe bin\TestRelease\generator-Tests.dll --result="TestResult-generator-Tests.xml" --output="bin\TestRelease\TestOutput-generator-Tests.txt" 'packages' is not recognized as an internal or external command, operable program or batch file. ##[error]build-tools\scripts\RunNUnitTests.targets(27,5): Error MSB3073: The command " packages/nunit.consolerunner/3.12.0/tools/nunit3-console.exe bin\TestRelease\generator-Tests.dll --result="TestResult-generator-Tests.xml" --output="bin\TestRelease\TestOutput-generator-Tests.txt"" exited with code 9009. D:\a\1\s\build-tools\scripts\RunNUnitTests.targets(27,5): error MSB3073: The command " packages/nunit.consolerunner/3.12.0/tools/nunit3-console.exe bin\TestRelease\generator-Tests.dll --result="TestResult-generator-Tests.xml" --output="bin\TestRelease\TestOutput-generator-Tests.txt"" exited with code 9009. The assumption is that we're not doing `nuget restore` now, so the package is installed into `~/.nuget/…`, and thus isn't found. Fix that by "using" `%(PackageReference.GeneratePathProperty)` in the bootstrap tasks so that we can obtain `$(PkgNUnit_ConsoleRunner)`, and *generate* that during `dotnet build -t:Prepare`. That way `RunNUnitTests.targets` has access to the value. --- Directory.Build.props | 4 ++++ Java.Interop.BootstrapTasks.sln | 6 ++++++ build-tools/PackagePaths/PackagePaths.csproj | 18 +++++++++++++++++ .../PackagePaths/PackagePaths.props.in | 7 +++++++ build-tools/PackagePaths/PackagePaths.targets | 20 +++++++++++++++++++ build-tools/scripts/RunNUnitTests.targets | 6 +++++- 6 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 build-tools/PackagePaths/PackagePaths.csproj create mode 100644 build-tools/PackagePaths/PackagePaths.props.in create mode 100644 build-tools/PackagePaths/PackagePaths.targets diff --git a/Directory.Build.props b/Directory.Build.props index fbd99082a..366f6fed4 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -38,6 +38,10 @@ Project="$(_OutputPath)MonoInfo.props" Condition="Exists('$(_OutputPath)MonoInfo.props')" /> + true diff --git a/Java.Interop.BootstrapTasks.sln b/Java.Interop.BootstrapTasks.sln index 7c7940742..245f58d80 100644 --- a/Java.Interop.BootstrapTasks.sln +++ b/Java.Interop.BootstrapTasks.sln @@ -9,6 +9,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Xamarin.Android.Tools.Andro EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VersionInfo", "build-tools\VersionInfo\VersionInfo.csproj", "{D5E50EDC-6CE3-4E8D-85A6-6920DF74E44C}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PackagePaths", "build-tools\PackagePaths\PackagePaths.csproj", "{0510FC04-44A2-41DE-A208-561DDE9F2AC6}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -27,6 +29,10 @@ Global {D5E50EDC-6CE3-4E8D-85A6-6920DF74E44C}.Debug|Any CPU.Build.0 = Debug|Any CPU {D5E50EDC-6CE3-4E8D-85A6-6920DF74E44C}.Release|Any CPU.ActiveCfg = Release|Any CPU {D5E50EDC-6CE3-4E8D-85A6-6920DF74E44C}.Release|Any CPU.Build.0 = Release|Any CPU + {0510FC04-44A2-41DE-A208-561DDE9F2AC6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0510FC04-44A2-41DE-A208-561DDE9F2AC6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0510FC04-44A2-41DE-A208-561DDE9F2AC6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0510FC04-44A2-41DE-A208-561DDE9F2AC6}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/build-tools/PackagePaths/PackagePaths.csproj b/build-tools/PackagePaths/PackagePaths.csproj new file mode 100644 index 000000000..b6fa164fa --- /dev/null +++ b/build-tools/PackagePaths/PackagePaths.csproj @@ -0,0 +1,18 @@ + + + + Exe + netstandard2.0 + + + + + + + + + + + + + \ No newline at end of file diff --git a/build-tools/PackagePaths/PackagePaths.props.in b/build-tools/PackagePaths/PackagePaths.props.in new file mode 100644 index 000000000..933850ac5 --- /dev/null +++ b/build-tools/PackagePaths/PackagePaths.props.in @@ -0,0 +1,7 @@ + + + + @CONSOLE_RUNNER_PATH@ + + + diff --git a/build-tools/PackagePaths/PackagePaths.targets b/build-tools/PackagePaths/PackagePaths.targets new file mode 100644 index 000000000..977494e5c --- /dev/null +++ b/build-tools/PackagePaths/PackagePaths.targets @@ -0,0 +1,20 @@ + + + + + + + + + + + + diff --git a/build-tools/scripts/RunNUnitTests.targets b/build-tools/scripts/RunNUnitTests.targets index b94bb5bc2..2ece387e0 100644 --- a/build-tools/scripts/RunNUnitTests.targets +++ b/build-tools/scripts/RunNUnitTests.targets @@ -1,11 +1,15 @@ + Debug <_TopDir>$(MSBuildThisFileDirectory)..\.. <_Runtime Condition=" '$(RUNTIME)' != '' ">$(RUNTIME) <_Runtime Condition=" '$(RUNTIME)' == '' And '$(OS)' != 'Windows_NT' ">mono --debug - <_NUnit>$(_Runtime) packages/nunit.consolerunner/3.12.0/tools/nunit3-console.exe + <_NUnit>$(_Runtime) $(PkgNUnit_ConsoleRunner)/tools/nunit3-console.exe <_Run Condition=" '$(RUN)' != '' ">--run="$(RUN)" Date: Mon, 7 Feb 2022 12:56:38 -0500 Subject: [PATCH 5/5] =?UTF-8?q?Address=20concerns,=20thoughts=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pobst doesn't want us to use `6.0.200`; use `6.0` for GitInfo.txt. Remove the `globalPackagesFolder` override; it shouldn't be needed anymore, given dab4b89fef2b79cd0ee2770268acb4e48736314b. --- GitInfo.txt | 2 +- NuGet.Config | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/GitInfo.txt b/GitInfo.txt index eb0e103f5..e0ea36fee 100644 --- a/GitInfo.txt +++ b/GitInfo.txt @@ -1 +1 @@ -6.0.200 +6.0 diff --git a/NuGet.Config b/NuGet.Config index fa33304f5..83325259b 100644 --- a/NuGet.Config +++ b/NuGet.Config @@ -11,7 +11,4 @@ - - - \ No newline at end of file