From c7b051436fac0e1df362140ae14d29ca54e3f934 Mon Sep 17 00:00:00 2001 From: Ankit Date: Wed, 9 May 2018 17:00:38 -0400 Subject: [PATCH 01/23] [msbuild] Replace all invocations of xbuild with msbuild - And map xbuild properties to msbuild ones for fallback paths `XBUILD_FRAMEWORK_FOLDERS_PATH -> TargetFrameworkFallbackSearchPaths` `MSBuildExtensionsPath -> MSBuildExtensionsPathFallbackPathsOverride` Note: Earlier with xbuild, the order of lookup for (example) `MSBuildExtensionsPath` was: 1. The value of $(MSBuildExtensionsPath), which we were setting to the in-tree path 2. /Library/Frameworks/Mono.framework/External/xbuild on osx 3. $prefix/lib/mono/xbuild (default location) And with the above changes, it will be: 1. The value of $(MSBuildExtensionsPath), which we are no longer setting, so the default path : $prefix/lib/mono/xbuild 2. The in-tree path, via $(MSBuildExtensionsPathFallbackPathsOverride) 3. /Library/Frameworks/Mono.framework/External/xbuild on osx Since, XI/XM targets are used via fallback path `/Library/Frameworks/Mono.framework/External/xbuild`, the default location doesn't matter. And the order of the remaining two remains the same. The same thing applies to the target frameworks also. --- Make.config | 2 +- fsharp/Makefile | 4 ++-- .../Tasks/GetPropertyValueTaskBase.cs | 2 +- msbuild/xbuild-in-place | 6 +++--- tests/Makefile | 8 ++++---- tests/common/ExecutionHelper.cs | 2 +- tests/common/mac/ProjectTestHelpers.cs | 15 +++++---------- tests/common/mac/project_building.mk | 4 ++-- tests/mac-binding-project/Makefile | 4 ++-- tests/mmptest/Makefile | 4 ++-- tests/mmptest/regression/Makefile | 4 ++-- tests/mtouch/Makefile | 4 ++-- tests/xharness/Jenkins.cs | 10 +++++----- tests/xharness/MakefileGenerator.cs | 4 ++-- 14 files changed, 34 insertions(+), 39 deletions(-) diff --git a/Make.config b/Make.config index 5e0d57c6a565..60d39f06fdca 100644 --- a/Make.config +++ b/Make.config @@ -251,7 +251,7 @@ SYSTEM_CSC=$(MONO_PREFIX)/bin/csc SYSTEM_SN=$(MONO_PREFIX)/bin/sn SYSTEM_MONO=$(MONO_PREFIX)/bin/mono SYSTEM_MONO32=$(MONO_PREFIX)/bin/mono32 -SYSTEM_XBUILD=$(MONO_PREFIX)/bin/xbuild +SYSTEM_XBUILD=$(MONO_PREFIX)/bin/msbuild SYSTEM_MSBUILD=unset MSBuildExtensionsPath && $(MONO_PREFIX)/bin/msbuild SYSTEM_RESGEN=$(MONO_PREFIX)/bin/resgen diff --git a/fsharp/Makefile b/fsharp/Makefile index 67154c773055..28a2fc0e1efb 100644 --- a/fsharp/Makefile +++ b/fsharp/Makefile @@ -156,8 +156,8 @@ build/%.dll: $(BIN_DIR)/%.dll | build/monotouch build/xamarinmacmobile build/xam $(Q) cp $< $@ $(Q_SN) MONO_CFG_DIR="$(TOP)" sn -q -R "$@" "$(PRODUCT_KEY_PATH)" -build.stamp: export XBUILD_FRAMEWORK_FOLDERS_PATH=$(IOS_DESTDIR)/Library/Frameworks/Mono.framework/External/xbuild-frameworks -build.stamp: export MSBuildExtensionsPath=$(IOS_DESTDIR)/Library/Frameworks/Mono.framework/External/xbuild +build.stamp: export TargetFrameworkFallbackSearchPaths=$(IOS_DESTDIR)/Library/Frameworks/Mono.framework/External/xbuild-frameworks +build.stamp: export MSBuildExtensionsPathFallbackPathsOverride=$(IOS_DESTDIR)/Library/Frameworks/Mono.framework/External/xbuild build.stamp: $(FSHARP_FILES) $(FSHARP_PATH)/Makefile $(MAKE) -C $(FSHARP_PATH)/src/fsharp build-proto $(MAKE) -C $(FSHARP_PATH)/src/fsharp $(FSHARP_BUILD_TARGETS) diff --git a/msbuild/Xamarin.iOS.Tasks.Core/Tasks/GetPropertyValueTaskBase.cs b/msbuild/Xamarin.iOS.Tasks.Core/Tasks/GetPropertyValueTaskBase.cs index 422ec8a533de..74eef97aee85 100644 --- a/msbuild/Xamarin.iOS.Tasks.Core/Tasks/GetPropertyValueTaskBase.cs +++ b/msbuild/Xamarin.iOS.Tasks.Core/Tasks/GetPropertyValueTaskBase.cs @@ -55,7 +55,7 @@ static bool TryRunMSBuildGetPropertyValueTarget (string path, string propertyNam arguments = string.Format ("{0} /p:TargetFrameworkIdentifier={1}", arguments, targetFrameworkIdentifier); } - var psi = new ProcessStartInfo ("/Library/Frameworks/Mono.framework/Commands/xbuild", arguments); + var psi = new ProcessStartInfo ("/Library/Frameworks/Mono.framework/Commands/msbuild", arguments); psi.UseShellExecute = false; psi.RedirectStandardError = true; diff --git a/msbuild/xbuild-in-place b/msbuild/xbuild-in-place index 25b1cf797165..aabe2791b775 100755 --- a/msbuild/xbuild-in-place +++ b/msbuild/xbuild-in-place @@ -5,14 +5,14 @@ build_in_place_dir="$(python -c "import os; print os.path.realpath('$self/../_ma xammac_framework_dir="$build_in_place_dir/Library/Frameworks/Xamarin.Mac.framework/Versions/Current" xbuild_external_dir="$build_in_place_dir/Library/Frameworks/Mono.framework/External" -export XBUILD_FRAMEWORK_FOLDERS_PATH="$xbuild_external_dir/xbuild-frameworks" -export MSBuildExtensionsPath="$xbuild_external_dir/xbuild" +export TargetFrameworkFallbackSearchPaths="$xbuild_external_dir/xbuild-frameworks" +export MSBuildExtensionsPathFallbackPathsOverride="$xbuild_external_dir/xbuild" XamarinMacFrameworkRoot="$xammac_framework_dir" TargetFrameworkIdentifier=Xamarin.Mac TargetFrameworkVersion=v2.0 -/Library/Frameworks/Mono.framework/Commands/xbuild \ +/Library/Frameworks/Mono.framework/Commands/msbuild \ /property:XamarinMacFrameworkRoot="$XamarinMacFrameworkRoot" \ /property:TargetFrameworkIdentifier="$TargetFrameworkIdentifier" \ /property:TargetFrameworkVersion="$TargetFrameworkVersion" \ diff --git a/tests/Makefile b/tests/Makefile index e9e90288bee1..d485a41495f8 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -41,8 +41,8 @@ EXEC_UNIT_SERVER=XCODE_DEVELOPER_ROOT=$(XCODE_DEVELOPER_ROOT) MONOTOUCH_ROOT=$(I export MD_APPLE_SDK_ROOT=$(abspath $(XCODE_DEVELOPER_ROOT)/../..) export MD_MTOUCH_SDK_ROOT=$(IOS_DESTDIR)/$(MONOTOUCH_PREFIX) -export XBUILD_FRAMEWORK_FOLDERS_PATH=$(IOS_DESTDIR)/Library/Frameworks/Mono.framework/External/xbuild-frameworks -export MSBuildExtensionsPath=$(IOS_DESTDIR)/Library/Frameworks/Mono.framework/External/xbuild +export TargetFrameworkFallbackSearchPaths=$(IOS_DESTDIR)/Library/Frameworks/Mono.framework/External/xbuild-frameworks +export MSBuildExtensionsPathFallbackPathsOverride=$(IOS_DESTDIR)/Library/Frameworks/Mono.framework/External/xbuild export XAMMAC_FRAMEWORK_PATH=$(MAC_DESTDIR)/Library/Frameworks/Xamarin.Mac.framework/Versions/Current export XamarinMacFrameworkRoot=$(MAC_DESTDIR)/Library/Frameworks/Xamarin.Mac.framework/Versions/Current @@ -176,10 +176,10 @@ Makefile.inc: xharness/xharness.exe -include Makefile.inc $(GUI_UNIT_PATH)/bin/net_4_5/GuiUnit.exe: - XBUILD_FRAMEWORK_FOLDERS_PATH=$(MAC_DESTDIR)/Library/Frameworks/Mono.framework/External/xbuild-frameworks MSBuildExtensionsPath=$(MAC_DESTDIR)/Library/Frameworks/Mono.framework/External/xbuild XamarinMacFrameworkRoot=$(MAC_DESTDIR)/Library/Frameworks/Xamarin.Mac.framework/Versions/Current $(SYSTEM_XBUILD) $(XBUILD_VERBOSITY) $(GUI_UNIT_PATH)/src/framework/GuiUnit_NET_4_5.csproj + TargetFrameworkFallbackSearchPaths=$(MAC_DESTDIR)/Library/Frameworks/Mono.framework/External/xbuild-frameworks MSBuildExtensionsPathFallbackPathsOverride=$(MAC_DESTDIR)/Library/Frameworks/Mono.framework/External/xbuild XamarinMacFrameworkRoot=$(MAC_DESTDIR)/Library/Frameworks/Xamarin.Mac.framework/Versions/Current $(SYSTEM_XBUILD) $(XBUILD_VERBOSITY) $(GUI_UNIT_PATH)/src/framework/GuiUnit_NET_4_5.csproj $(GUI_UNIT_PATH)/bin/xammac_mobile/GuiUnit.exe: - XBUILD_FRAMEWORK_FOLDERS_PATH=$(MAC_DESTDIR)/Library/Frameworks/Mono.framework/External/xbuild-frameworks MSBuildExtensionsPath=$(MAC_DESTDIR)/Library/Frameworks/Mono.framework/External/xbuild XamarinMacFrameworkRoot=$(MAC_DESTDIR)/Library/Frameworks/Xamarin.Mac.framework/Versions/Current $(SYSTEM_XBUILD) $(XBUILD_VERBOSITY) $(GUI_UNIT_PATH)/src/framework/GuiUnit_xammac_mobile.csproj + TargetFrameworkFallbackSearchPaths=$(MAC_DESTDIR)/Library/Frameworks/Mono.framework/External/xbuild-frameworks MSBuildExtensionsPathFallbackPathsOverride=$(MAC_DESTDIR)/Library/Frameworks/Mono.framework/External/xbuild XamarinMacFrameworkRoot=$(MAC_DESTDIR)/Library/Frameworks/Xamarin.Mac.framework/Versions/Current $(SYSTEM_XBUILD) $(XBUILD_VERBOSITY) $(GUI_UNIT_PATH)/src/framework/GuiUnit_xammac_mobile.csproj Makefile-mac.inc: xharness/xharness.exe $(Q_GEN) $(SYSTEM_MONO) --debug $< $(XHARNESS_VERBOSITY) --configure --autoconf --mac --rootdir $(CURDIR) diff --git a/tests/common/ExecutionHelper.cs b/tests/common/ExecutionHelper.cs index afa2770dedca..7cb576acd048 100644 --- a/tests/common/ExecutionHelper.cs +++ b/tests/common/ExecutionHelper.cs @@ -356,7 +356,7 @@ class XBuild public static string ToolPath { get { - return "/Library/Frameworks/Mono.framework/Commands/xbuild"; + return "/Library/Frameworks/Mono.framework/Commands/msbuild"; } } diff --git a/tests/common/mac/ProjectTestHelpers.cs b/tests/common/mac/ProjectTestHelpers.cs index 3999177c3335..cee161edb719 100644 --- a/tests/common/mac/ProjectTestHelpers.cs +++ b/tests/common/mac/ProjectTestHelpers.cs @@ -225,23 +225,18 @@ public static string RunAndAssert (string exe, StringBuilder args, string stepNa // In most cases we generate projects in tmp and this is not needed. But nuget and test projects can make that hard public static void CleanUnifiedProject (string csprojTarget, bool useMSBuild = false) { - RunAndAssert ("/Library/Frameworks/Mono.framework/Commands/" + (useMSBuild ? "msbuild" : "xbuild"), new StringBuilder (csprojTarget + " /t:clean"), "Clean"); + RunAndAssert ("/Library/Frameworks/Mono.framework/Commands/" + (useMSBuild ? "msbuild" : "msbuild"), new StringBuilder (csprojTarget + " /t:clean"), "Clean"); } public static string BuildProject (string csprojTarget, bool isUnified, bool diagnosticMSBuild = false, bool shouldFail = false, bool useMSBuild = false, bool release = false, string[] environment = null) { - if (Environment.GetEnvironmentVariable ("XM_FORCE_MSBUILD") != null) - useMSBuild = true; - string rootDirectory = FindRootDirectory (); // TODO - This is not enough for MSBuild to really work. We need stuff to have it not use system targets! // These are required to have xbuild use are local build instead of system install - if (!useMSBuild) { - Environment.SetEnvironmentVariable ("XBUILD_FRAMEWORK_FOLDERS_PATH", rootDirectory + "/Library/Frameworks/Mono.framework/External/xbuild-frameworks"); - Environment.SetEnvironmentVariable ("MSBuildExtensionsPath", rootDirectory + "/Library/Frameworks/Mono.framework/External/xbuild"); - Environment.SetEnvironmentVariable ("XAMMAC_FRAMEWORK_PATH", rootDirectory + "/Library/Frameworks/Xamarin.Mac.framework/Versions/Current"); - } + Environment.SetEnvironmentVariable ("TargetFrameworkFallbackSearchPaths", rootDirectory + "/Library/Frameworks/Mono.framework/External/xbuild-frameworks"); + Environment.SetEnvironmentVariable ("MSBuildExtensionsPathFallbackPathsOverride", rootDirectory + "/Library/Frameworks/Mono.framework/External/xbuild"); + Environment.SetEnvironmentVariable ("XAMMAC_FRAMEWORK_PATH", rootDirectory + "/Library/Frameworks/Xamarin.Mac.framework/Versions/Current"); // This is to force build to use our mmp and not system mmp StringBuilder buildArgs = new StringBuilder (); @@ -268,7 +263,7 @@ public static string BuildProject (string csprojTarget, bool isUnified, bool dia }; if (isUnified) - return RunAndAssert ("/Library/Frameworks/Mono.framework/Commands/" + (useMSBuild ? "msbuild" : "xbuild"), buildArgs, "Compile", shouldFail, getBuildProjectErrorInfo, environment); + return RunAndAssert ("/Library/Frameworks/Mono.framework/Commands/msbuild", buildArgs, "Compile", shouldFail, getBuildProjectErrorInfo, environment); else return RunAndAssert ("/Applications/Visual Studio.app/Contents/MacOS/vstool", buildArgs, "Compile", shouldFail, getBuildProjectErrorInfo, environment); } diff --git a/tests/common/mac/project_building.mk b/tests/common/mac/project_building.mk index 1694dad2ba51..5779134722a2 100644 --- a/tests/common/mac/project_building.mk +++ b/tests/common/mac/project_building.mk @@ -11,8 +11,8 @@ SOURCES = $(TEST_SRC) \ ALL_SOURCE_FILES = $(TEST_SRC) $(SOURCES) $(EXTRA_FILES) Makefile export MD_APPLE_SDK_ROOT=$(shell dirname `dirname $(XCODE_DEVELOPER_ROOT)`) -export XBUILD_FRAMEWORK_FOLDERS_PATH=$(MAC_DESTDIR)/Library/Frameworks/Mono.framework/External/xbuild-frameworks -export MSBuildExtensionsPath=$(MAC_DESTDIR)/Library/Frameworks/Mono.framework/External/xbuild +export TargetFrameworkFallbackSearchPaths=$(MAC_DESTDIR)/Library/Frameworks/Mono.framework/External/xbuild-frameworks +export MSBuildExtensionsPathFallbackPathsOverride=$(MAC_DESTDIR)/Library/Frameworks/Mono.framework/External/xbuild export XamarinMacFrameworkRoot=$(MAC_DESTDIR)/Library/Frameworks/Xamarin.Mac.framework/Versions/Current ifeq ($(V)$(BUILD_REVISION),) diff --git a/tests/mac-binding-project/Makefile b/tests/mac-binding-project/Makefile index 82b2a5e71f17..2a8eea5ba8c7 100644 --- a/tests/mac-binding-project/Makefile +++ b/tests/mac-binding-project/Makefile @@ -2,8 +2,8 @@ TOP=../.. include $(TOP)/Make.config export MD_APPLE_SDK_ROOT=$(shell dirname `dirname $(XCODE_DEVELOPER_ROOT)`) -export XBUILD_FRAMEWORK_FOLDERS_PATH=$(MAC_DESTDIR)/Library/Frameworks/Mono.framework/External/xbuild-frameworks -export MSBuildExtensionsPath=$(MAC_DESTDIR)/Library/Frameworks/Mono.framework/External/xbuild +export TargetFrameworkFallbackSearchPaths=$(MAC_DESTDIR)/Library/Frameworks/Mono.framework/External/xbuild-frameworks +export MSBuildExtensionsPathFallbackPathsOverride=$(MAC_DESTDIR)/Library/Frameworks/Mono.framework/External/xbuild export XamarinMacFrameworkRoot=$(MAC_DESTDIR)/Library/Frameworks/Xamarin.Mac.framework/Versions/Current export XAMMAC_FRAMEWORK_PATH=$(MAC_DESTDIR)/Library/Frameworks/Xamarin.Mac.framework/Versions/Current diff --git a/tests/mmptest/Makefile b/tests/mmptest/Makefile index 7360d28891f4..0af6ff70e2ca 100644 --- a/tests/mmptest/Makefile +++ b/tests/mmptest/Makefile @@ -1,8 +1,8 @@ TOP = ../.. include $(TOP)/Make.config -export XBUILD_FRAMEWORK_FOLDERS_PATH=$(MAC_DESTDIR)/Library/Frameworks/Mono.framework/External/xbuild-frameworks -export MSBuildExtensionsPath=$(MAC_DESTDIR)/Library/Frameworks/Mono.framework/External/xbuild +export TargetFrameworkFallbackSearchPaths=$(MAC_DESTDIR)/Library/Frameworks/Mono.framework/External/xbuild-frameworks +export MSBuildExtensionsPathFallbackPathsOverride=$(MAC_DESTDIR)/Library/Frameworks/Mono.framework/External/xbuild export XAMMAC_FRAMEWORK_PATH=$(MAC_DESTDIR)/Library/Frameworks/Xamarin.Mac.framework/Versions/Current export XamarinMacFrameworkRoot=$(MAC_DESTDIR)/Library/Frameworks/Xamarin.Mac.framework/Versions/Current diff --git a/tests/mmptest/regression/Makefile b/tests/mmptest/regression/Makefile index 86a6cfcea8a8..e7131d2859ce 100644 --- a/tests/mmptest/regression/Makefile +++ b/tests/mmptest/regression/Makefile @@ -5,8 +5,8 @@ include $(TOP)/Make.config MMP=$(MAC_DESTDIR)/Library/Frameworks/Xamarin.Mac.framework/Versions/Current/bin/mmp export MD_APPLE_SDK_ROOT=$(shell dirname `dirname $(XCODE_DEVELOPER_ROOT)`) -export XBUILD_FRAMEWORK_FOLDERS_PATH=$(MAC_DESTDIR)/Library/Frameworks/Mono.framework/External/xbuild-frameworks -export MSBuildExtensionsPath=$(MAC_DESTDIR)/Library/Frameworks/Mono.framework/External/xbuild +export TargetFrameworkFallbackSearchPaths=$(MAC_DESTDIR)/Library/Frameworks/Mono.framework/External/xbuild-frameworks +export MSBuildExtensionsPathFallbackPathsOverride=$(MAC_DESTDIR)/Library/Frameworks/Mono.framework/External/xbuild export XamarinMacFrameworkRoot=$(MAC_DESTDIR)/Library/Frameworks/Xamarin.Mac.framework/Versions/Current diff --git a/tests/mtouch/Makefile b/tests/mtouch/Makefile index 0e2d9b2ac680..1caa1b4ab093 100644 --- a/tests/mtouch/Makefile +++ b/tests/mtouch/Makefile @@ -3,8 +3,8 @@ TOP=../.. include $(TOP)/Make.config export MD_MTOUCH_SDK_ROOT=$(IOS_DESTDIR)/$(MONOTOUCH_PREFIX) -export XBUILD_FRAMEWORK_FOLDERS_PATH=$(IOS_DESTDIR)/Library/Frameworks/Mono.framework/External/xbuild-frameworks -export MSBuildExtensionsPath=$(IOS_DESTDIR)/Library/Frameworks/Mono.framework/External/xbuild +export TargetFrameworkFallbackSearchPaths=$(IOS_DESTDIR)/Library/Frameworks/Mono.framework/External/xbuild-frameworks +export MSBuildExtensionsPathFallbackPathsOverride=$(IOS_DESTDIR)/Library/Frameworks/Mono.framework/External/xbuild check: run-tests diff --git a/tests/xharness/Jenkins.cs b/tests/xharness/Jenkins.cs index 292639ac9426..2009c4906847 100644 --- a/tests/xharness/Jenkins.cs +++ b/tests/xharness/Jenkins.cs @@ -2401,7 +2401,7 @@ protected void SetEnvironmentVariables (Process process) case TestPlatform.watchOS: process.StartInfo.EnvironmentVariables ["MD_APPLE_SDK_ROOT"] = Harness.XcodeRoot; process.StartInfo.EnvironmentVariables ["MD_MTOUCH_SDK_ROOT"] = Path.Combine (Harness.IOS_DESTDIR, "Library", "Frameworks", "Xamarin.iOS.framework", "Versions", "Current"); - process.StartInfo.EnvironmentVariables ["XBUILD_FRAMEWORK_FOLDERS_PATH"] = Path.Combine (Harness.IOS_DESTDIR, "Library", "Frameworks", "Mono.framework", "External", "xbuild-frameworks"); + process.StartInfo.EnvironmentVariables ["TargetFrameworkFallbackSearchPaths"] = Path.Combine (Harness.IOS_DESTDIR, "Library", "Frameworks", "Mono.framework", "External", "xbuild-frameworks"); process.StartInfo.EnvironmentVariables ["MSBuildExtensionsPath"] = Path.Combine (Harness.IOS_DESTDIR, "Library", "Frameworks", "Mono.framework", "External", "xbuild"); break; case TestPlatform.Mac: @@ -2411,7 +2411,7 @@ protected void SetEnvironmentVariables (Process process) case TestPlatform.Mac_UnifiedXM45: case TestPlatform.Mac_UnifiedXM45_32: process.StartInfo.EnvironmentVariables ["MD_APPLE_SDK_ROOT"] = Harness.XcodeRoot; - process.StartInfo.EnvironmentVariables ["XBUILD_FRAMEWORK_FOLDERS_PATH"] = Path.Combine (Harness.MAC_DESTDIR, "Library", "Frameworks", "Mono.framework", "External", "xbuild-frameworks"); + process.StartInfo.EnvironmentVariables ["TargetFrameworkFallbackSearchPaths"] = Path.Combine (Harness.MAC_DESTDIR, "Library", "Frameworks", "Mono.framework", "External", "xbuild-frameworks"); process.StartInfo.EnvironmentVariables ["MSBuildExtensionsPath"] = Path.Combine (Harness.MAC_DESTDIR, "Library", "Frameworks", "Mono.framework", "External", "xbuild"); process.StartInfo.EnvironmentVariables ["XamarinMacFrameworkRoot"] = Path.Combine (Harness.MAC_DESTDIR, "Library", "Frameworks", "Xamarin.Mac.framework", "Versions", "Current"); process.StartInfo.EnvironmentVariables ["XAMMAC_FRAMEWORK_PATH"] = Path.Combine (Harness.MAC_DESTDIR, "Library", "Frameworks", "Xamarin.Mac.framework", "Versions", "Current"); @@ -2419,7 +2419,7 @@ protected void SetEnvironmentVariables (Process process) case TestPlatform.All: // Don't set: // MSBuildExtensionsPath - // XBUILD_FRAMEWORK_FOLDERS_PATH + // TargetFrameworkFallbackSearchPaths // because these values used by both XM and XI and we can't set it to two different values at the same time. // Any test that depends on these values should not be using 'TestPlatform.All' process.StartInfo.EnvironmentVariables ["MD_APPLE_SDK_ROOT"] = Harness.XcodeRoot; @@ -2680,7 +2680,7 @@ protected override async Task ExecuteAsync () await RestoreNugetsAsync (log, resource); using (var xbuild = new Process ()) { - xbuild.StartInfo.FileName = UseMSBuild ? "msbuild" : "xbuild"; + xbuild.StartInfo.FileName = UseMSBuild ? "msbuild" : "msbuild"; var args = new StringBuilder (); args.Append ("/verbosity:diagnostic "); if (SpecifyPlatform) @@ -2716,7 +2716,7 @@ async Task CleanProjectAsync (Log log, string project_file, string project_platf { // Don't require the desktop resource here, this shouldn't be that resource sensitive using (var xbuild = new Process ()) { - xbuild.StartInfo.FileName = "xbuild"; + xbuild.StartInfo.FileName = "msbuild"; var args = new StringBuilder (); args.Append ("/verbosity:diagnostic "); if (project_platform != null) diff --git a/tests/xharness/MakefileGenerator.cs b/tests/xharness/MakefileGenerator.cs index d2e9a492c2cb..b4ddaa85115d 100644 --- a/tests/xharness/MakefileGenerator.cs +++ b/tests/xharness/MakefileGenerator.cs @@ -181,8 +181,8 @@ public static void CreateMacMakefile (Harness harness, IEnumerable ta writer.WriteLine (); writer.WriteLine ("MD_APPLE_SDK_ROOT_EVALUATED:=$(shell dirname `dirname $(XCODE_DEVELOPER_ROOT)`)"); - var enviromentalVariables = new Dictionary () { { "XBUILD_FRAMEWORK_FOLDERS_PATH", "$(MAC_DESTDIR)/Library/Frameworks/Mono.framework/External/xbuild-frameworks"}, - { "MSBuildExtensionsPath", "$(MAC_DESTDIR)/Library/Frameworks/Mono.framework/External/xbuild"}, + var enviromentalVariables = new Dictionary () { { "TargetFrameworkFallbackSearchPaths", "$(MAC_DESTDIR)/Library/Frameworks/Mono.framework/External/xbuild-frameworks"}, + { "MSBuildExtensionsPathFallbackPaths", "$(MAC_DESTDIR)/Library/Frameworks/Mono.framework/External/xbuild"}, { "MD_APPLE_SDK_ROOT", "$(MD_APPLE_SDK_ROOT_EVALUATED)"} }; From 256035e11dbb02cd8d149fb142c06db22fd5158b Mon Sep 17 00:00:00 2001 From: Ankit Date: Wed, 9 May 2018 17:50:22 -0400 Subject: [PATCH 02/23] [msbuild] Update xbuild assembly references to msbuild ones .. and switch from v4.0 to the new .Core assemblies. --- .../Xamarin.Mac.Tasks.Core.csproj | 11 +++++------ msbuild/Xamarin.Mac.Tasks/Xamarin.Mac.Tasks.csproj | 9 ++++----- .../Xamarin.MacDev.Tasks.Core.csproj | 7 +++---- .../Xamarin.MacDev.Tasks/Xamarin.MacDev.Tasks.csproj | 7 +++---- .../Xamarin.iOS.Tasks.Core.csproj | 9 ++++----- msbuild/Xamarin.iOS.Tasks/Xamarin.iOS.Tasks.csproj | 6 +++--- .../Xamarin.iOS.Tasks.Tests.csproj | 7 +++---- 7 files changed, 25 insertions(+), 31 deletions(-) diff --git a/msbuild/Xamarin.Mac.Tasks.Core/Xamarin.Mac.Tasks.Core.csproj b/msbuild/Xamarin.Mac.Tasks.Core/Xamarin.Mac.Tasks.Core.csproj index 8b8c956adf44..5587059785ec 100644 --- a/msbuild/Xamarin.Mac.Tasks.Core/Xamarin.Mac.Tasks.Core.csproj +++ b/msbuild/Xamarin.Mac.Tasks.Core/Xamarin.Mac.Tasks.Core.csproj @@ -24,11 +24,10 @@ - - - - - + + + + @@ -53,4 +52,4 @@ Xamarin.MacDev.Tasks.Core - \ No newline at end of file + diff --git a/msbuild/Xamarin.Mac.Tasks/Xamarin.Mac.Tasks.csproj b/msbuild/Xamarin.Mac.Tasks/Xamarin.Mac.Tasks.csproj index 842b8a801a65..db34a0e1d5ba 100644 --- a/msbuild/Xamarin.Mac.Tasks/Xamarin.Mac.Tasks.csproj +++ b/msbuild/Xamarin.Mac.Tasks/Xamarin.Mac.Tasks.csproj @@ -23,11 +23,10 @@ - - - - - + + + + diff --git a/msbuild/Xamarin.MacDev.Tasks.Core/Xamarin.MacDev.Tasks.Core.csproj b/msbuild/Xamarin.MacDev.Tasks.Core/Xamarin.MacDev.Tasks.Core.csproj index 632c63ccce99..f28c37b5092a 100644 --- a/msbuild/Xamarin.MacDev.Tasks.Core/Xamarin.MacDev.Tasks.Core.csproj +++ b/msbuild/Xamarin.MacDev.Tasks.Core/Xamarin.MacDev.Tasks.Core.csproj @@ -33,10 +33,9 @@ - - - - + + + diff --git a/msbuild/Xamarin.MacDev.Tasks/Xamarin.MacDev.Tasks.csproj b/msbuild/Xamarin.MacDev.Tasks/Xamarin.MacDev.Tasks.csproj index 61692007b979..ed47aba4f58a 100644 --- a/msbuild/Xamarin.MacDev.Tasks/Xamarin.MacDev.Tasks.csproj +++ b/msbuild/Xamarin.MacDev.Tasks/Xamarin.MacDev.Tasks.csproj @@ -33,10 +33,9 @@ - - - - + + + diff --git a/msbuild/Xamarin.iOS.Tasks.Core/Xamarin.iOS.Tasks.Core.csproj b/msbuild/Xamarin.iOS.Tasks.Core/Xamarin.iOS.Tasks.Core.csproj index 91f579db7c49..45fc042c9530 100644 --- a/msbuild/Xamarin.iOS.Tasks.Core/Xamarin.iOS.Tasks.Core.csproj +++ b/msbuild/Xamarin.iOS.Tasks.Core/Xamarin.iOS.Tasks.Core.csproj @@ -32,14 +32,13 @@ true - + - - - + + + - diff --git a/msbuild/Xamarin.iOS.Tasks/Xamarin.iOS.Tasks.csproj b/msbuild/Xamarin.iOS.Tasks/Xamarin.iOS.Tasks.csproj index 962b723cb94f..fb7b1341be7f 100644 --- a/msbuild/Xamarin.iOS.Tasks/Xamarin.iOS.Tasks.csproj +++ b/msbuild/Xamarin.iOS.Tasks/Xamarin.iOS.Tasks.csproj @@ -95,9 +95,9 @@ - - - + + + diff --git a/msbuild/tests/Xamarin.iOS.Tasks.Tests/Xamarin.iOS.Tasks.Tests.csproj b/msbuild/tests/Xamarin.iOS.Tasks.Tests/Xamarin.iOS.Tasks.Tests.csproj index 4f3d36e7304c..c80a1264f0d6 100644 --- a/msbuild/tests/Xamarin.iOS.Tasks.Tests/Xamarin.iOS.Tasks.Tests.csproj +++ b/msbuild/tests/Xamarin.iOS.Tasks.Tests/Xamarin.iOS.Tasks.Tests.csproj @@ -32,10 +32,9 @@ - - - - + + + ..\..\..\packages\NUnit.2.6.4\lib\nunit.framework.dll From a5670f270775459131a9a7099bd921d3457dcf84 Mon Sep 17 00:00:00 2001 From: Ankit Date: Thu, 17 May 2018 13:43:11 -0400 Subject: [PATCH 03/23] [msbuild] Port the tasks and tests to use new msbuild API Mono's msbuild does not have implementation assemblies for the older APIs (think `Microsoft.Build.Engine`), and so as part of the port to msbuild we switch over to using the newer APIs. With this commit, we are buildable again (with lots of test failures!). --- .../ProjectsTests/BindingProject.cs | 4 +- .../ProjectsTests/Bug60536.cs | 11 +- .../Extensions/ExtensionTestBase.cs | 4 +- .../ProjectsTests/Extensions/WatchKit.cs | 16 +- .../ProjectsTests/NativeReferences.cs | 19 +- .../ProjectsTests/ProjectTest.cs | 4 +- .../TargetTests/TargetTests.cs | 215 +++++++++--------- .../TestHelpers/Logger.cs | 1 - .../TestHelpers/TestBase.cs | 40 +++- .../TestHelpers/TestEngine.cs | 37 ++- 10 files changed, 202 insertions(+), 149 deletions(-) diff --git a/msbuild/tests/Xamarin.iOS.Tasks.Tests/ProjectsTests/BindingProject.cs b/msbuild/tests/Xamarin.iOS.Tasks.Tests/ProjectsTests/BindingProject.cs index a30ebf880834..6f431baee16c 100644 --- a/msbuild/tests/Xamarin.iOS.Tasks.Tests/ProjectsTests/BindingProject.cs +++ b/msbuild/tests/Xamarin.iOS.Tasks.Tests/ProjectsTests/BindingProject.cs @@ -24,7 +24,7 @@ public void BuildTest () AppBundlePath = mtouchPaths.AppBundlePath; var dllPath = Path.Combine(mtouchPaths.ProjectBinPath, "bindings-test.dll"); - Engine.GlobalProperties.SetProperty ("Platform", Platform); + Engine.ProjectCollection.SetGlobalProperty ("Platform", Platform); RunTarget (proj, "Build", 0); Assert.IsTrue (File.Exists (dllPath), "{1} binding dll does not exist: {0} ", dllPath, Platform); @@ -43,7 +43,7 @@ public void FrameworkTest () AppBundlePath = mtouchPaths.AppBundlePath; var dllPath = Path.Combine(mtouchPaths.ProjectBinPath, "bindings-test.dll"); - Engine.GlobalProperties.SetProperty ("Platform", Platform); + Engine.ProjectCollection.SetGlobalProperty ("Platform", Platform); RunTarget (proj, "Build", 0); Assert.IsTrue (File.Exists (dllPath), "{1} binding dll does not exist: {0} ", dllPath, Platform); diff --git a/msbuild/tests/Xamarin.iOS.Tasks.Tests/ProjectsTests/Bug60536.cs b/msbuild/tests/Xamarin.iOS.Tasks.Tests/ProjectsTests/Bug60536.cs index 4d3cecea167d..8140a93d611b 100644 --- a/msbuild/tests/Xamarin.iOS.Tasks.Tests/ProjectsTests/Bug60536.cs +++ b/msbuild/tests/Xamarin.iOS.Tasks.Tests/ProjectsTests/Bug60536.cs @@ -3,9 +3,9 @@ using System.Linq; using System.Collections; -using NUnit.Framework; +using Microsoft.Build.Evaluation; -using Microsoft.Build.BuildEngine; +using NUnit.Framework; namespace Xamarin.iOS.Tasks { @@ -30,8 +30,8 @@ public void TestACToolTaskCatchesJsonException () var project = SetupProject (Engine, csproj); AppBundlePath = mtouchPaths ["app_bundlepath"]; - Engine.GlobalProperties.SetProperty("Platform", platform); - Engine.GlobalProperties.SetProperty("Configuration", config); + Engine.ProjectCollection.SetGlobalProperty("Platform", platform); + Engine.ProjectCollection.SetGlobalProperty("Configuration", config); if (clean) { RunTarget (project, "Clean"); @@ -56,8 +56,9 @@ public void TestACToolTaskCatchesJsonException () } project = SetupProject (Engine, mtouchPaths.ProjectCSProjPath); + var projectInstance = project.CreateProjectInstance (); - Engine.BuildProject (project, new [] { target }, new Hashtable { {"Platform", "iPhone"} }, BuildSettings.None); + Engine.BuildProject (projectInstance, new [] { target }, new Hashtable { {"Platform", "iPhone"} }); if (Engine.Logger.ErrorEvents.Count != 1) { string messages = string.Empty; if (Engine.Logger.ErrorEvents.Count > 0) diff --git a/msbuild/tests/Xamarin.iOS.Tasks.Tests/ProjectsTests/Extensions/ExtensionTestBase.cs b/msbuild/tests/Xamarin.iOS.Tasks.Tests/ProjectsTests/Extensions/ExtensionTestBase.cs index 289ddbe10280..d638f2505827 100644 --- a/msbuild/tests/Xamarin.iOS.Tasks.Tests/ProjectsTests/Extensions/ExtensionTestBase.cs +++ b/msbuild/tests/Xamarin.iOS.Tasks.Tests/ProjectsTests/Extensions/ExtensionTestBase.cs @@ -35,8 +35,8 @@ public void BuildExtension (string hostAppName, string extensionName, string bun AppBundlePath = mtouchPaths ["app_bundlepath"]; string extensionPath = Path.Combine(AppBundlePath, "PlugIns", extensionName + ".appex"); - Engine.GlobalProperties.SetProperty ("Platform", platform); - Engine.GlobalProperties.SetProperty ("Configuration", config); + Engine.ProjectCollection.SetGlobalProperty ("Platform", platform); + Engine.ProjectCollection.SetGlobalProperty ("Configuration", config); RunTarget (proj, "Clean"); Assert.IsFalse (Directory.Exists (AppBundlePath), "{1}: App bundle exists after cleanup: {0} ", AppBundlePath, bundlePath); diff --git a/msbuild/tests/Xamarin.iOS.Tasks.Tests/ProjectsTests/Extensions/WatchKit.cs b/msbuild/tests/Xamarin.iOS.Tasks.Tests/ProjectsTests/Extensions/WatchKit.cs index 9ed2f5725853..1a2c591aadf6 100644 --- a/msbuild/tests/Xamarin.iOS.Tasks.Tests/ProjectsTests/Extensions/WatchKit.cs +++ b/msbuild/tests/Xamarin.iOS.Tasks.Tests/ProjectsTests/Extensions/WatchKit.cs @@ -38,7 +38,7 @@ public void InvalidBundleIdTest () File.WriteAllText (appInfoPath, appInfoContents.Replace ("com.xamarin.MyWatchApp", "com.xamarin.MyWatchAppX")); var proj = SetupProject (Engine, mtouchPaths.ProjectCSProjPath); - Engine.GlobalProperties.SetProperty ("Platform", Platform); + Engine.ProjectCollection.SetGlobalProperty ("Platform", Platform); AppBundlePath = mtouchPaths ["app_bundlepath"]; RunTarget (proj, "Build", 2); Assert.AreEqual ("The App Extension 'WatchExtension' has an invalid CFBundleIdentifier (com.xamarin.MyWatchApp.WatchExtension), it does not begin with the main app bundle's CFBundleIdentifier (com.xamarin.MyWatchAppX).", Engine.Logger.ErrorEvents [0].Message, "#1"); @@ -61,12 +61,12 @@ public void CreateIpa () AppBundlePath = mtouchPaths.AppBundlePath; - Engine.GlobalProperties.SetProperty ("Platform", Platform); - Engine.GlobalProperties.SetProperty ("BuildIpa", "true"); - Engine.GlobalProperties.SetProperty ("IpaIncludeArtwork", "true"); - Engine.GlobalProperties.SetProperty ("CodesignProvision", "Automatic"); // Provisioning profile - Engine.GlobalProperties.SetProperty ("CodesignKey", "iPhone Developer"); - Engine.GlobalProperties.SetProperty ("Configuration", configuration); + Engine.ProjectCollection.SetGlobalProperty ("Platform", Platform); + Engine.ProjectCollection.SetGlobalProperty ("BuildIpa", "true"); + Engine.ProjectCollection.SetGlobalProperty ("IpaIncludeArtwork", "true"); + Engine.ProjectCollection.SetGlobalProperty ("CodesignProvision", "Automatic"); // Provisioning profile + Engine.ProjectCollection.SetGlobalProperty ("CodesignKey", "iPhone Developer"); + Engine.ProjectCollection.SetGlobalProperty ("Configuration", configuration); RunTarget (proj, "Clean"); Assert.IsFalse (Directory.Exists (AppBundlePath), "{1}: App bundle exists after cleanup: {0} ", AppBundlePath, Platform); @@ -103,7 +103,7 @@ public void CreateIpa () string wkPath = "WatchKitSupport/WK"; Assert.Contains (wkPath, lines, wkPath + " does not exist"); - var ipaIncludeArtwork = proj.GetEvaluatedProperty ("IpaIncludeArtwork"); + var ipaIncludeArtwork = proj.GetPropertyValue ("IpaIncludeArtwork"); Assert.IsTrue (output.Contains ("iTunesMetadata.plist"), string.Format ("The ipa should contain at least one iTunesMetadata.plist file if we are using an AppStore config and IpaIncludeArtwork is true. IpaIncludeArtwork: {0}", ipaIncludeArtwork)); RunTarget (proj, "Clean"); diff --git a/msbuild/tests/Xamarin.iOS.Tasks.Tests/ProjectsTests/NativeReferences.cs b/msbuild/tests/Xamarin.iOS.Tasks.Tests/ProjectsTests/NativeReferences.cs index c74924a3b190..13dbd4ca404b 100644 --- a/msbuild/tests/Xamarin.iOS.Tasks.Tests/ProjectsTests/NativeReferences.cs +++ b/msbuild/tests/Xamarin.iOS.Tasks.Tests/ProjectsTests/NativeReferences.cs @@ -1,5 +1,6 @@ using System; using System.IO; +using System.Linq; using NUnit.Framework; namespace Xamarin.iOS.Tasks { @@ -16,12 +17,12 @@ public void BasicTest () { var mtouchPaths = SetupProjectPaths ("MyTabbedApplication", "../", true, Platform); - Engine.GlobalProperties.SetProperty ("Platform", Platform); + Engine.ProjectCollection.SetGlobalProperty ("Platform", Platform); var proj = SetupProject (Engine, mtouchPaths.ProjectCSProjPath); - var nr = proj.AddNewItem ("NativeReference", Path.Combine (".", "..", "..", "..", "tests", "test-libraries", ".libs", "ios", "XTest.framework")); - nr.SetMetadata ("IsCxx", "False"); - nr.SetMetadata ("Kind", "Framework"); + var nr = proj.AddItem ("NativeReference", Path.Combine (".", "..", "..", "..", "tests", "test-libraries", ".libs", "ios", "XTest.framework")).First (); + nr.SetMetadataValue ("IsCxx", "False"); + nr.SetMetadataValue ("Kind", "Framework"); AppBundlePath = mtouchPaths.AppBundlePath; @@ -40,14 +41,14 @@ public void WithIncrementalBuilds () var mtouchPaths = SetupProjectPaths ("MyiOSAppWithBinding", "../", true, Platform); - Engine.GlobalProperties.SetProperty ("Platform", Platform); + Engine.ProjectCollection.SetGlobalProperty ("Platform", Platform); var proj = SetupProject (Engine, mtouchPaths.ProjectCSProjPath); - proj.GlobalProperties.SetProperty ("MtouchFastDev", "true"); - proj.GlobalProperties.SetProperty ("MtouchExtraArgs", "-vvvv"); - proj.GlobalProperties.SetProperty ("MtouchArch", "ARM64"); // only use ARM64 to speed up the build. - proj.GlobalProperties.SetProperty ("MtouchLink", "Full"); // also to speed up the build. + proj.SetGlobalProperty ("MtouchFastDev", "true"); + proj.SetGlobalProperty ("MtouchExtraArgs", "-vvvv"); + proj.SetGlobalProperty ("MtouchArch", "ARM64"); // only use ARM64 to speed up the build. + proj.SetGlobalProperty ("MtouchLink", "Full"); // also to speed up the build. AppBundlePath = mtouchPaths.AppBundlePath; diff --git a/msbuild/tests/Xamarin.iOS.Tasks.Tests/ProjectsTests/ProjectTest.cs b/msbuild/tests/Xamarin.iOS.Tasks.Tests/ProjectsTests/ProjectTest.cs index dc401e2840b8..00609a9cc2c2 100644 --- a/msbuild/tests/Xamarin.iOS.Tasks.Tests/ProjectsTests/ProjectTest.cs +++ b/msbuild/tests/Xamarin.iOS.Tasks.Tests/ProjectsTests/ProjectTest.cs @@ -42,8 +42,8 @@ public string BuildProject (string appName, string platform, string config, int var proj = SetupProject (Engine, csproj); AppBundlePath = mtouchPaths ["app_bundlepath"]; - Engine.GlobalProperties.SetProperty("Platform", platform); - Engine.GlobalProperties.SetProperty("Configuration", config); + Engine.ProjectCollection.SetGlobalProperty("Platform", platform); + Engine.ProjectCollection.SetGlobalProperty("Configuration", config); if (clean) { RunTarget (proj, "Clean"); diff --git a/msbuild/tests/Xamarin.iOS.Tasks.Tests/TargetTests/TargetTests.cs b/msbuild/tests/Xamarin.iOS.Tasks.Tests/TargetTests/TargetTests.cs index 39cabef0af1e..f22df5697988 100644 --- a/msbuild/tests/Xamarin.iOS.Tasks.Tests/TargetTests/TargetTests.cs +++ b/msbuild/tests/Xamarin.iOS.Tasks.Tests/TargetTests/TargetTests.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.IO; using System.Linq; @@ -5,6 +6,7 @@ using Mono.Cecil; using NUnit.Framework; using Xamarin.MacDev; +using Microsoft.Build.Execution; namespace Xamarin.iOS.Tasks { @@ -135,30 +137,30 @@ static bool BundleResourceExists (string path, ref int extra) [Test] public void GetReferencedAssemblies_Executable () { - RunTarget (MonoTouchProject, TargetName.ResolveReferences); - var references = MonoTouchProject.GetEvaluatedItemsByName ("ReferencePath").ToArray (); + RunTargetOnInstance (MonoTouchProjectInstance, TargetName.ResolveReferences); + var references = MonoTouchProjectInstance.GetItems ("ReferencePath").ToArray (); Assert.AreEqual (6, references.Length, "#1"); - Assert.IsTrue (references.Any (t => t.Include.Contains ("MyLibrary")), "#2"); - Assert.IsTrue (references.Any (t => t.Include.Contains ("System")), "#3a"); - Assert.IsTrue (references.Any (t => t.Include.Contains ("System.Xml")), "#3b"); - Assert.IsTrue (references.Any (t => t.Include.Contains ("System.Core")), "#3c"); - Assert.IsTrue (references.Any (t => t.Include.Contains ("mscorlib")), "#3d"); - Assert.IsTrue (references.Any (t => t.Include.Contains ("Xamarin.iOS")), "#3e"); + Assert.IsTrue (references.Any (t => t.EvaluatedInclude.Contains ("MyLibrary")), "#2"); + Assert.IsTrue (references.Any (t => t.EvaluatedInclude.Contains ("System")), "#3a"); + Assert.IsTrue (references.Any (t => t.EvaluatedInclude.Contains ("System.Xml")), "#3b"); + Assert.IsTrue (references.Any (t => t.EvaluatedInclude.Contains ("System.Core")), "#3c"); + Assert.IsTrue (references.Any (t => t.EvaluatedInclude.Contains ("mscorlib")), "#3d"); + Assert.IsTrue (references.Any (t => t.EvaluatedInclude.Contains ("Xamarin.iOS")), "#3e"); } [Test] public void GetReferencedAssemblies_Library () { - RunTarget (LibraryProject, TargetName.ResolveReferences); - var references = LibraryProject.GetEvaluatedItemsByName ("ReferencePath").ToArray (); + RunTargetOnInstance (LibraryProjectInstance, TargetName.ResolveReferences); + var references = LibraryProjectInstance.GetItems ("ReferencePath").ToArray (); Assert.AreEqual (5, references.Length, "#1"); - Assert.IsTrue (references.Any (t => t.Include.Contains ("System")), "#2a"); - Assert.IsTrue (references.Any (t => t.Include.Contains ("System.Xml")), "#2b"); - Assert.IsTrue (references.Any (t => t.Include.Contains ("System.Core")), "#2c"); - Assert.IsTrue (references.Any (t => t.Include.Contains ("mscorlib")), "#2d"); - Assert.IsTrue (references.Any (t => t.Include.Contains ("Xamarin.iOS")), "#2e"); + Assert.IsTrue (references.Any (t => t.EvaluatedInclude.Contains ("System")), "#2a"); + Assert.IsTrue (references.Any (t => t.EvaluatedInclude.Contains ("System.Xml")), "#2b"); + Assert.IsTrue (references.Any (t => t.EvaluatedInclude.Contains ("System.Core")), "#2c"); + Assert.IsTrue (references.Any (t => t.EvaluatedInclude.Contains ("mscorlib")), "#2d"); + Assert.IsTrue (references.Any (t => t.EvaluatedInclude.Contains ("Xamarin.iOS")), "#2e"); } [Test] @@ -167,7 +169,7 @@ public void BuildExecutable () var expectedFiles = ExpectedExecutableFiles; int extra = 0; - RunTarget (MonoTouchProject, TargetName.Build); + RunTargetOnInstance (MonoTouchProjectInstance, TargetName.Build); Assert.IsTrue (Directory.Exists (AppBundlePath), "#1"); foreach (var file in expectedFiles) @@ -187,7 +189,7 @@ public void BuildExecutable () [Test] public void CopyContentToBundle () { - RunTarget (MonoTouchProject, TargetName.CopyResourcesToBundle); + RunTargetOnInstance (MonoTouchProjectInstance, TargetName.CopyResourcesToBundle); foreach (var v in ExpectedExecutableBundleResources) Assert.IsTrue (File.Exists (v) || Directory.Exists (v), string.Format ("{0} was not copied to the bundle", Path.GetFullPath (v))); @@ -196,12 +198,12 @@ public void CopyContentToBundle () [Test] public void CleanExecutable () { - RunTarget (MonoTouchProject, TargetName.Clean); + RunTargetOnInstance (MonoTouchProjectInstance, TargetName.Clean); Assert.IsFalse (Directory.Exists (MonoTouchProjectBinPath), "#1a"); Assert.IsFalse (Directory.Exists (MonoTouchProjectObjPath), "#1b"); - RunTarget (MonoTouchProject, TargetName.Build); - RunTarget (MonoTouchProject, TargetName.Clean); + RunTargetOnInstance (MonoTouchProjectInstance, TargetName.Build); + RunTargetOnInstance (MonoTouchProjectInstance, TargetName.Clean); Assert.IsEmpty (Directory.GetDirectories (MonoTouchProjectBinPath, "*.dSYM", SearchOption.AllDirectories), "#2a"); Assert.IsEmpty (Directory.GetFiles (MonoTouchProjectBinPath, "*.*", SearchOption.AllDirectories), "#2b"); Assert.IsFalse (Directory.Exists (MonoTouchProjectObjPath), "#2c"); @@ -210,12 +212,12 @@ public void CleanExecutable () [Test] public void CleanLibrary () { - RunTarget (LibraryProject, TargetName.Clean); + RunTargetOnInstance (LibraryProjectInstance, TargetName.Clean); Assert.IsFalse (Directory.Exists (LibraryProjectBinPath), "#1a"); Assert.IsFalse (Directory.Exists (LibraryProjectObjPath), "#1b"); - RunTarget (LibraryProject, TargetName.Build); - RunTarget (LibraryProject, TargetName.Clean); + RunTargetOnInstance (LibraryProjectInstance, TargetName.Build); + RunTargetOnInstance (LibraryProjectInstance, TargetName.Clean); Assert.IsEmpty (Directory.GetFiles (LibraryProjectBinPath, "*.*", SearchOption.AllDirectories), "#2a"); Assert.IsFalse (Directory.Exists (LibraryProjectObjPath), "#2b"); } @@ -223,7 +225,7 @@ public void CleanLibrary () [Test] public void CompileInterfaceDefinitions_Library () { - RunTarget (LibraryProject, TargetName.CompileInterfaceDefinitions); + RunTargetOnInstance (LibraryProjectInstance, TargetName.CompileInterfaceDefinitions); Assert.IsNotEmpty (Directory.GetFiles (LibraryProjectObjPath, "*.*", SearchOption.AllDirectories), "#1"); } @@ -236,14 +238,14 @@ public void OptimizePngs_DefaultValue () [Test] public void OptimizePngs_True () { - MonoTouchProject.AddNewPropertyGroup (true).AddNewProperty ("OptimizePNGs", "True"); + MonoTouchProjectInstance.SetProperty ("OptimizePNGs", "True"); OptimizePngs_Core (true); } [Test] public void OptimizePngs_False () { - MonoTouchProject.AddNewPropertyGroup (true).AddNewProperty ("OptimizePNGs", "False"); + MonoTouchProjectInstance.SetProperty ("OptimizePNGs", "False"); OptimizePngs_Core (false); } @@ -252,7 +254,7 @@ void OptimizePngs_Core (bool shouldBeDifferent) var originalFile = Path.Combine (MonoTouchProjectPath, "Resources", "image.png"); var optimisedFile = Path.Combine (AppBundlePath, "image.png"); - RunTarget (MonoTouchProject, TargetName.Build); + RunTargetOnInstance (MonoTouchProjectInstance, TargetName.Build); Assert.IsTrue (File.Exists (optimisedFile), "#1"); if (shouldBeDifferent) @@ -355,8 +357,8 @@ public void BuildLibrary () [Test] public void BuildLibrary_NoInterfaceDefinitions () { - foreach (var item in LibraryProject.GetEvaluatedItemsByName ("InterfaceDefinition")) - LibraryProject.RemoveItem ((Microsoft.Build.BuildEngine.BuildItem)item); + LibraryProject.RemoveItems (LibraryProject.GetItems ("InterfaceDefinition")); + LibraryProjectInstance = LibraryProject.CreateProjectInstance (); BuildLibraryCore (ExpectedLibraryEmbeddedResources.Where (s => !s.Contains ("storyboardc")).ToArray ()); } @@ -364,9 +366,9 @@ public void BuildLibrary_NoInterfaceDefinitions () void BuildLibraryCore (string[] expectedResources) { var library = Path.Combine (LibraryProjectBinPath, "MyLibrary.dll"); - RunTarget (LibraryProject, TargetName.Build); + RunTargetOnInstance (LibraryProjectInstance, TargetName.Build); - Assert.IsTrue (string.IsNullOrEmpty (LibraryProject.GetEvaluatedProperty ("AppBundleDir")), "#1"); + Assert.IsTrue (string.IsNullOrEmpty (LibraryProjectInstance.GetPropertyValue ("AppBundleDir")), "#1"); var entries = Directory.GetFileSystemEntries (LibraryProjectBinPath); Assert.AreEqual (2, entries.Length, "#1"); Assert.IsTrue (File.Exists (library), "#2"); @@ -384,29 +386,29 @@ void BuildLibraryCore (string[] expectedResources) public void GenerateBundleName_ExecutableProject () { // Initially the AssemblyName is set and there is no app bundle dir - Assert.AreEqual ("MySingleView", MonoTouchProject.GetEvaluatedProperty ("AssemblyName"), "#1"); - Assert.IsTrue (string.IsNullOrEmpty (MonoTouchProject.GetEvaluatedProperty ("AppBundleDir")), "#2"); + Assert.AreEqual ("MySingleView", MonoTouchProjectInstance.GetPropertyValue ("AssemblyName"), "#1"); + Assert.IsTrue (string.IsNullOrEmpty (MonoTouchProjectInstance.GetPropertyValue ("AppBundleDir")), "#2"); // Now we should have an AppBundleDir - RunTarget (MonoTouchProject, TargetName.GenerateBundleName); - Assert.AreEqual ("bin/iPhoneSimulator/Debug/MySingleView.app", MonoTouchProject.GetEvaluatedProperty ("AppBundleDir"), "#3"); + RunTargetOnInstance (MonoTouchProjectInstance, TargetName.GenerateBundleName); + Assert.AreEqual ("bin/iPhoneSimulator/Debug/MySingleView.app", MonoTouchProjectInstance.GetPropertyValue ("AppBundleDir"), "#3"); } [Test] public void PackLibraryResources_ExecutableProject () { - RunTarget (MonoTouchProject, TargetName.PackLibraryResources); - var embeddedResources = MonoTouchProject.GetEvaluatedItemsByName ("EmbeddedResource").ToArray (); + RunTargetOnInstance (MonoTouchProjectInstance, TargetName.PackLibraryResources); + var embeddedResources = MonoTouchProjectInstance.GetItems ("EmbeddedResource").ToArray (); Assert.AreEqual (2, embeddedResources.Length, "#1"); - Assert.IsTrue (embeddedResources.Any (i => i.FinalItemSpec == "LinkedEmbeddedResource.txt"), "#1"); - Assert.IsTrue (embeddedResources.Any (i => i.FinalItemSpec == Path.Combine ("Folder", "EmbeddedResource.txt")), "#2"); + Assert.IsTrue (embeddedResources.Any (i => i.EvaluatedInclude == "LinkedEmbeddedResource.txt"), "#1"); + Assert.IsTrue (embeddedResources.Any (i => i.EvaluatedInclude == Path.Combine ("Folder", "EmbeddedResource.txt")), "#2"); } [Test] public void PackLibraryResources_LibraryProject () { - RunTarget (LibraryProject, TargetName.PackLibraryResources); - var embeddedResources = LibraryProject.GetEvaluatedItemsByName ("EmbeddedResource").ToArray (); + RunTargetOnInstance (LibraryProjectInstance, TargetName.PackLibraryResources); + var embeddedResources = LibraryProjectInstance.GetItems ("EmbeddedResource").ToArray (); Assert.AreEqual (13, embeddedResources.Length, "#1"); } @@ -414,8 +416,8 @@ public void PackLibraryResources_LibraryProject () public void UnpackLibraryResources_ExecutableProject () { // We unpack 4 embedded resources from the library project into BundleResources - RunTarget (MonoTouchProject, TargetName.Build); - var bundleResources = MonoTouchProject.GetEvaluatedItemsByName ("_BundleResourceWithLogicalName").ToArray (); + RunTargetOnInstance (MonoTouchProjectInstance, TargetName.Build); + var bundleResources = MonoTouchProjectInstance.GetItems ("_BundleResourceWithLogicalName").ToArray (); Assert.IsTrue (bundleResources.Length >= 33, "#1"); } @@ -423,8 +425,8 @@ public void UnpackLibraryResources_ExecutableProject () public void UnpackLibraryResources_LibraryProject () { // We should not unpack any EmbeddedResources into BundleResources - RunTarget (LibraryProject, TargetName.Build); - var bundleResources = LibraryProject.GetEvaluatedItemsByName ("_BundleResourceWithLogicalName").ToArray (); + RunTargetOnInstance (LibraryProjectInstance, TargetName.Build); + var bundleResources = LibraryProjectInstance.GetItems ("_BundleResourceWithLogicalName").ToArray (); Assert.AreEqual (11, bundleResources.Length, "#1"); } @@ -439,35 +441,35 @@ public void BundleResources () plist.SetMinimumOSVersion ("7.0"); plist.Save (path, true); - RunTarget (MonoTouchProject, TargetName.CollectBundleResources); - - var bundleItems = MonoTouchProject.GetEvaluatedItemsByName ("_BundleResourceWithLogicalName").ToArray (); - Assert.IsTrue (bundleItems.Any (i => i.FinalItemSpec == Path.Combine ("Folder", "BundleResource.txt") && i.GetMetadata ("LogicalName") == "Folder/BundleResource.txt"), "#1"); - Assert.IsTrue (bundleItems.Any (i => i.FinalItemSpec == Path.Combine ("Folder", "Content.txt") && i.GetMetadata ("LogicalName") == "Folder/Content.txt"), "#2"); - Assert.IsTrue (bundleItems.Any (i => i.FinalItemSpec == "LinkedBundleResource.txt" && i.GetMetadata ("LogicalName") == "Folder/LinkedBundleResource.txt"), "#3"); - Assert.IsTrue (bundleItems.Any (i => i.FinalItemSpec == "LinkedContent.txt" && i.GetMetadata ("LogicalName") == "Folder/LinkedContent.txt"), "#4"); - Assert.IsTrue (bundleItems.Any (i => i.FinalItemSpec == Path.Combine (actool, "AppIcons29x29.png") && i.GetMetadata ("LogicalName") == "AppIcons29x29.png"), "#5"); - Assert.IsTrue (bundleItems.Any (i => i.FinalItemSpec == Path.Combine (actool, "AppIcons29x29@2x.png") && i.GetMetadata ("LogicalName") == "AppIcons29x29@2x.png"), "#6"); - Assert.IsTrue (bundleItems.Any (i => i.FinalItemSpec == Path.Combine (actool, "AppIcons40x40@2x.png") && i.GetMetadata ("LogicalName") == "AppIcons40x40@2x.png"), "#7"); - Assert.IsTrue (bundleItems.Any (i => i.FinalItemSpec == Path.Combine (actool, "AppIcons57x57.png") && i.GetMetadata ("LogicalName") == "AppIcons57x57.png"), "#8"); - Assert.IsTrue (bundleItems.Any (i => i.FinalItemSpec == Path.Combine (actool, "AppIcons57x57@2x.png") && i.GetMetadata ("LogicalName") == "AppIcons57x57@2x.png"), "#9"); - Assert.IsTrue (bundleItems.Any (i => i.FinalItemSpec == Path.Combine (actool, "AppIcons60x60@2x.png") && i.GetMetadata ("LogicalName") == "AppIcons60x60@2x.png"), "#10"); - Assert.IsTrue (bundleItems.Any (i => i.FinalItemSpec == Path.Combine (actool, "LaunchImage-568h@2x.png") && i.GetMetadata ("LogicalName") == "LaunchImage-568h@2x.png"), "#11"); - Assert.IsTrue (bundleItems.Any (i => i.FinalItemSpec == Path.Combine (actool, "LaunchImage.png") && i.GetMetadata ("LogicalName") == "LaunchImage.png"), "#12"); - Assert.IsTrue (bundleItems.Any (i => i.FinalItemSpec == Path.Combine (actool, "LaunchImage@2x.png") && i.GetMetadata ("LogicalName") == "LaunchImage@2x.png"), "#13"); - Assert.IsTrue (bundleItems.Any (i => i.FinalItemSpec == Path.Combine (ibtool, "MainStoryboard.storyboardc", "1-view-2.nib") && i.GetMetadata ("LogicalName") == "MainStoryboard.storyboardc/1-view-2.nib"), "#14"); - Assert.IsTrue (bundleItems.Any (i => i.FinalItemSpec == Path.Combine (ibtool, "MainStoryboard.storyboardc", "Info.plist") && i.GetMetadata ("LogicalName") == "MainStoryboard.storyboardc/Info.plist"), "#15"); - Assert.IsTrue (bundleItems.Any (i => i.FinalItemSpec == Path.Combine (ibtool, "MainStoryboard.storyboardc", "UIViewController-1.nib") && i.GetMetadata ("LogicalName") == "MainStoryboard.storyboardc/UIViewController-1.nib"), "#16"); + RunTargetOnInstance (MonoTouchProjectInstance, TargetName.CollectBundleResources); + + var bundleItems = MonoTouchProjectInstance.GetItems ("_BundleResourceWithLogicalName").ToArray (); + Assert.IsTrue (bundleItems.Any (i => i.EvaluatedInclude == Path.Combine ("Folder", "BundleResource.txt") && i.GetMetadataValue ("LogicalName") == "Folder/BundleResource.txt"), "#1"); + Assert.IsTrue (bundleItems.Any (i => i.EvaluatedInclude == Path.Combine ("Folder", "Content.txt") && i.GetMetadataValue ("LogicalName") == "Folder/Content.txt"), "#2"); + Assert.IsTrue (bundleItems.Any (i => i.EvaluatedInclude == "LinkedBundleResource.txt" && i.GetMetadataValue ("LogicalName") == "Folder/LinkedBundleResource.txt"), "#3"); + Assert.IsTrue (bundleItems.Any (i => i.EvaluatedInclude == "LinkedContent.txt" && i.GetMetadataValue ("LogicalName") == "Folder/LinkedContent.txt"), "#4"); + Assert.IsTrue (bundleItems.Any (i => i.EvaluatedInclude == Path.Combine (actool, "AppIcons29x29.png") && i.GetMetadataValue ("LogicalName") == "AppIcons29x29.png"), "#5"); + Assert.IsTrue (bundleItems.Any (i => i.EvaluatedInclude == Path.Combine (actool, "AppIcons29x29@2x.png") && i.GetMetadataValue ("LogicalName") == "AppIcons29x29@2x.png"), "#6"); + Assert.IsTrue (bundleItems.Any (i => i.EvaluatedInclude == Path.Combine (actool, "AppIcons40x40@2x.png") && i.GetMetadataValue ("LogicalName") == "AppIcons40x40@2x.png"), "#7"); + Assert.IsTrue (bundleItems.Any (i => i.EvaluatedInclude == Path.Combine (actool, "AppIcons57x57.png") && i.GetMetadataValue ("LogicalName") == "AppIcons57x57.png"), "#8"); + Assert.IsTrue (bundleItems.Any (i => i.EvaluatedInclude == Path.Combine (actool, "AppIcons57x57@2x.png") && i.GetMetadataValue ("LogicalName") == "AppIcons57x57@2x.png"), "#9"); + Assert.IsTrue (bundleItems.Any (i => i.EvaluatedInclude == Path.Combine (actool, "AppIcons60x60@2x.png") && i.GetMetadataValue ("LogicalName") == "AppIcons60x60@2x.png"), "#10"); + Assert.IsTrue (bundleItems.Any (i => i.EvaluatedInclude == Path.Combine (actool, "LaunchImage-568h@2x.png") && i.GetMetadataValue ("LogicalName") == "LaunchImage-568h@2x.png"), "#11"); + Assert.IsTrue (bundleItems.Any (i => i.EvaluatedInclude == Path.Combine (actool, "LaunchImage.png") && i.GetMetadataValue ("LogicalName") == "LaunchImage.png"), "#12"); + Assert.IsTrue (bundleItems.Any (i => i.EvaluatedInclude == Path.Combine (actool, "LaunchImage@2x.png") && i.GetMetadataValue ("LogicalName") == "LaunchImage@2x.png"), "#13"); + Assert.IsTrue (bundleItems.Any (i => i.EvaluatedInclude == Path.Combine (ibtool, "MainStoryboard.storyboardc", "1-view-2.nib") && i.GetMetadataValue ("LogicalName") == "MainStoryboard.storyboardc/1-view-2.nib"), "#14"); + Assert.IsTrue (bundleItems.Any (i => i.EvaluatedInclude == Path.Combine (ibtool, "MainStoryboard.storyboardc", "Info.plist") && i.GetMetadataValue ("LogicalName") == "MainStoryboard.storyboardc/Info.plist"), "#15"); + Assert.IsTrue (bundleItems.Any (i => i.EvaluatedInclude == Path.Combine (ibtool, "MainStoryboard.storyboardc", "UIViewController-1.nib") && i.GetMetadataValue ("LogicalName") == "MainStoryboard.storyboardc/UIViewController-1.nib"), "#16"); if (bundleItems.Length > ExpectedExecutableBundleResources.Length) { - Assert.IsTrue (bundleItems.Any (i => i.FinalItemSpec == Path.Combine (ibtool, "en.lproj", "TranslatedView.nib", "runtime.nib") && i.GetMetadata ("LogicalName") == "en.lproj/TranslatedView.nib/runtime.nib"), "#17"); - Assert.IsTrue (bundleItems.Any (i => i.FinalItemSpec == Path.Combine (ibtool, "FolderView.nib", "runtime.nib") && i.GetMetadata ("LogicalName") == "FolderView.nib/runtime.nib"), "#18"); - Assert.IsTrue (bundleItems.Any (i => i.FinalItemSpec == Path.Combine (ibtool, "iPhoneView.nib", "runtime.nib") && i.GetMetadata ("LogicalName") == "iPhoneView.nib/runtime.nib"), "#19"); + Assert.IsTrue (bundleItems.Any (i => i.EvaluatedInclude == Path.Combine (ibtool, "en.lproj", "TranslatedView.nib", "runtime.nib") && i.GetMetadataValue ("LogicalName") == "en.lproj/TranslatedView.nib/runtime.nib"), "#17"); + Assert.IsTrue (bundleItems.Any (i => i.EvaluatedInclude == Path.Combine (ibtool, "FolderView.nib", "runtime.nib") && i.GetMetadataValue ("LogicalName") == "FolderView.nib/runtime.nib"), "#18"); + Assert.IsTrue (bundleItems.Any (i => i.EvaluatedInclude == Path.Combine (ibtool, "iPhoneView.nib", "runtime.nib") && i.GetMetadataValue ("LogicalName") == "iPhoneView.nib/runtime.nib"), "#19"); } else { - Assert.IsTrue (bundleItems.Any (i => i.FinalItemSpec == Path.Combine (ibtool, "en.lproj", "TranslatedView.nib") && i.GetMetadata ("LogicalName") == "en.lproj/TranslatedView.nib"), "#17"); - Assert.IsTrue (bundleItems.Any (i => i.FinalItemSpec == Path.Combine (ibtool, "FolderView.nib") && i.GetMetadata ("LogicalName") == "FolderView.nib"), "#18"); - Assert.IsTrue (bundleItems.Any (i => i.FinalItemSpec == Path.Combine (ibtool, "iPhoneView.nib") && i.GetMetadata ("LogicalName") == "iPhoneView.nib"), "#19"); + Assert.IsTrue (bundleItems.Any (i => i.EvaluatedInclude == Path.Combine (ibtool, "en.lproj", "TranslatedView.nib") && i.GetMetadataValue ("LogicalName") == "en.lproj/TranslatedView.nib"), "#17"); + Assert.IsTrue (bundleItems.Any (i => i.EvaluatedInclude == Path.Combine (ibtool, "FolderView.nib") && i.GetMetadataValue ("LogicalName") == "FolderView.nib"), "#18"); + Assert.IsTrue (bundleItems.Any (i => i.EvaluatedInclude == Path.Combine (ibtool, "iPhoneView.nib") && i.GetMetadataValue ("LogicalName") == "iPhoneView.nib"), "#19"); } - Assert.IsTrue (bundleItems.Any (i => i.FinalItemSpec == Path.Combine ("Resources", "image.png") && i.GetMetadata ("LogicalName") == "image.png"), "#20"); + Assert.IsTrue (bundleItems.Any (i => i.EvaluatedInclude == Path.Combine ("Resources", "image.png") && i.GetMetadataValue ("LogicalName") == "image.png"), "#20"); } [Test (Description = "Xambug #39137")] @@ -484,12 +486,14 @@ public void AddAppIcon_NoClean() plist.SetMinimumOSVersion ("7.0"); plist.Save (path, true); - RunTarget (project, TargetName.CompileImageAssets); + var projectInstance = project.CreateProjectInstance (); + RunTargetOnInstance (projectInstance, TargetName.CompileImageAssets, 0); - var bundleItemsNoAppIcon = project.GetEvaluatedItemsByName ("_BundleResourceWithLogicalName").ToArray (); - Assert.IsFalse (bundleItemsNoAppIcon.Any (i => i.FinalItemSpec == Path.Combine (actool, "AppIcons60x60@2x.png") && i.GetMetadata ("LogicalName") == "AppIcons60x60@2x.png"), "#1"); + var bundleItemsNoAppIcon = projectInstance.GetItems ("_BundleResourceWithLogicalName").ToArray (); + Assert.IsFalse (bundleItemsNoAppIcon.Any (i => i.EvaluatedInclude == Path.Combine (actool, "AppIcons60x60@2x.png") && i.GetMetadataValue ("LogicalName") == "AppIcons60x60@2x.png"), "#1"); project = SetupProject (Engine, MonoTouchProjectCSProjPath); + projectInstance = project.CreateProjectInstance (); // Put a thread.sleep so that we get noticeable timestamps. Thread.Sleep (1000); @@ -499,10 +503,10 @@ public void AddAppIcon_NoClean() // Re-run the task with app icon set this time and no clean. // The task should be aware the app icon is now being used. - RunTarget (project, TargetName.CompileImageAssets); + RunTargetOnInstance (projectInstance, TargetName.CompileImageAssets, 0); - var bundleItemsWithAppIcon = project.GetEvaluatedItemsByName ("_BundleResourceWithLogicalName").ToArray (); - Assert.IsTrue (bundleItemsWithAppIcon.Any (i => i.FinalItemSpec == Path.Combine (actool, "AppIcons60x60@2x.png") && i.GetMetadata ("LogicalName") == "AppIcons60x60@2x.png"), "#2"); + var bundleItemsWithAppIcon = projectInstance.GetItems ("_BundleResourceWithLogicalName").ToArray (); + Assert.IsTrue (bundleItemsWithAppIcon.Any (i => i.EvaluatedInclude == Path.Combine (actool, "AppIcons60x60@2x.png") && i.GetMetadataValue ("LogicalName") == "AppIcons60x60@2x.png"), "#2"); } [Test (Description = "Xambug #16331")] @@ -512,11 +516,11 @@ public void Disappearing_Bundle_Resource () string resourceGone = resource + ".disabled"; try { File.Move (resource, resourceGone); - RunTarget_WithErrors (MonoTouchProject, "_CollectBundleResources"); - var bundleItems = MonoTouchProject.GetEvaluatedItemsByName ("_BundleResourceWithLogicalName").ToArray (); + RunTarget_WithErrors (MonoTouchProjectInstance, "_CollectBundleResources"); + var bundleItems = MonoTouchProjectInstance.GetItems ("_BundleResourceWithLogicalName").ToArray (); Assert.IsNotNull (bundleItems, "#1"); Assert.IsTrue (bundleItems.Length >= 17, "#2"); - Assert.IsFalse (bundleItems.Any (i => i.FinalItemSpec == Path.Combine ("Folder", "BundleResource.txt")), "#3"); + Assert.IsFalse (bundleItems.Any (i => i.EvaluatedInclude == Path.Combine ("Folder", "BundleResource.txt")), "#3"); } finally { File.Move (resourceGone, resource); } @@ -529,11 +533,11 @@ public void Disappearing_Content () string resourceGone = resource + ".disabled"; try { File.Move (resource, resourceGone); - RunTarget_WithErrors (MonoTouchProject, "_CollectBundleResources"); - var bundleItems = MonoTouchProject.GetEvaluatedItemsByName ("_BundleResourceWithLogicalName").ToArray (); + RunTarget_WithErrors (MonoTouchProjectInstance, "_CollectBundleResources"); + var bundleItems = MonoTouchProjectInstance.GetItems ("_BundleResourceWithLogicalName").ToArray (); Assert.IsNotNull (bundleItems, "#1"); Assert.IsTrue (bundleItems.Length >= 17, "#2"); - Assert.IsFalse (bundleItems.Any (i => i.FinalItemSpec == Path.Combine ("Folder", "Content.txt")), "#3"); + Assert.IsFalse (bundleItems.Any (i => i.EvaluatedInclude == Path.Combine ("Folder", "Content.txt")), "#3"); } finally { File.Move (resourceGone, resource); } @@ -542,29 +546,31 @@ public void Disappearing_Content () [Test] public void DetectAppManifest_ExecutableProject () { - RunTarget (MonoTouchProject, TargetName.DetectAppManifest); - Assert.IsNotNull (MonoTouchProject.GetEvaluatedProperty ("_AppManifest"), "#1"); + RunTargetOnInstance (MonoTouchProjectInstance, TargetName.DetectAppManifest); + Assert.IsFalse (string.IsNullOrEmpty(MonoTouchProjectInstance.GetPropertyValue ("_AppManifest")), "#1"); } [Test] public void DetectAppManifest_ExecutableProject_NoPList () { RemoveItemsByName (MonoTouchProject, "None"); - RunTarget_WithErrors (MonoTouchProject, TargetName.DetectAppManifest); - Assert.IsNull (MonoTouchProject.GetEvaluatedProperty ("_AppManifest"), "#1"); + MonoTouchProjectInstance = MonoTouchProject.CreateProjectInstance (); + + RunTarget_WithErrors (MonoTouchProjectInstance, TargetName.DetectAppManifest); + Assert.IsNull (MonoTouchProjectInstance.GetPropertyValue ("_AppManifest"), "#1"); } [Test] public void DetectAppManifest_ExecutableProject_TwoPLists () { RemoveItemsByName (MonoTouchProject, "None"); + MonoTouchProjectInstance = MonoTouchProject.CreateProjectInstance (); - var group = MonoTouchProject.AddNewItemGroup (); - group.AddNewItem ("None", "Fake/Info.plist"); - group.AddNewItem ("None", "Info.plist"); + MonoTouchProjectInstance.AddItem ("None", "Fake/Info.plist"); + MonoTouchProjectInstance.AddItem ("None", "Info.plist"); - RunTarget (MonoTouchProject, TargetName.DetectAppManifest); - Assert.AreEqual ("Info.plist", MonoTouchProject.GetEvaluatedProperty ("_AppManifest"), "#1"); + RunTargetOnInstance (MonoTouchProjectInstance, TargetName.DetectAppManifest); + Assert.AreEqual ("Info.plist", MonoTouchProjectInstance.GetPropertyValue ("_AppManifest"), "#1"); } [Test] @@ -573,12 +579,13 @@ public void DetectAppManifest_ExecutableProject_LinkedPList () string linkedPlist = CreateTempFile (Path.Combine (TempDir, "Linked.plist")); RemoveItemsByName (MonoTouchProject, "None"); - var group = MonoTouchProject.AddNewItemGroup (); - group.AddNewItem ("None", linkedPlist); - group.ToArray ().Last ().SetMetadata ("Link", "Info.plist"); + MonoTouchProjectInstance = MonoTouchProject.CreateProjectInstance (); + + var item = MonoTouchProjectInstance.AddItem ("None", linkedPlist); + item.SetMetadata ("Link", "Info.plist"); - RunTarget (MonoTouchProject, TargetName.DetectAppManifest); - Assert.AreEqual (linkedPlist, MonoTouchProject.GetEvaluatedProperty ("_AppManifest"), "#1"); + RunTargetOnInstance (MonoTouchProjectInstance, TargetName.DetectAppManifest); + Assert.AreEqual (linkedPlist, MonoTouchProjectInstance.GetPropertyValue ("_AppManifest"), "#1"); } [Test] @@ -587,20 +594,20 @@ public void DetectAppManifest_ExecutableProject_LogicalNamePList () string logicalPlist = CreateTempFile (Path.Combine (TempDir, "Logical.plist")); RemoveItemsByName (MonoTouchProject, "None"); + MonoTouchProjectInstance = MonoTouchProject.CreateProjectInstance (); - var group = MonoTouchProject.AddNewItemGroup (); - group.AddNewItem ("None", logicalPlist); - group.ToArray ().Last ().SetMetadata ("LogicalName", "Info.plist"); + var item = MonoTouchProjectInstance.AddItem ("None", logicalPlist); + item.SetMetadata ("LogicalName", "Info.plist"); - RunTarget (MonoTouchProject, TargetName.DetectAppManifest); - Assert.AreEqual (logicalPlist, MonoTouchProject.GetEvaluatedProperty ("_AppManifest"), "#1"); + RunTargetOnInstance (MonoTouchProjectInstance, TargetName.DetectAppManifest); + Assert.AreEqual (logicalPlist, MonoTouchProjectInstance.GetPropertyValue ("_AppManifest"), "#1"); } [Test] public void DetectAppManifest_LibraryProject () { - RunTarget (LibraryProject, TargetName.DetectAppManifest); - Assert.IsNull (LibraryProject.GetEvaluatedProperty ("_AppManifest"), "#1"); + RunTargetOnInstance (LibraryProjectInstance, TargetName.DetectAppManifest); + Assert.IsNullOrEmpty (LibraryProjectInstance.GetPropertyValue ("_AppManifest"), "#1"); } } } diff --git a/msbuild/tests/Xamarin.iOS.Tasks.Tests/TestHelpers/Logger.cs b/msbuild/tests/Xamarin.iOS.Tasks.Tests/TestHelpers/Logger.cs index e6775b2f4116..161f30a7ea61 100644 --- a/msbuild/tests/Xamarin.iOS.Tasks.Tests/TestHelpers/Logger.cs +++ b/msbuild/tests/Xamarin.iOS.Tasks.Tests/TestHelpers/Logger.cs @@ -5,7 +5,6 @@ using System.Runtime.Remoting; using System.Runtime.Serialization.Formatters.Binary; using System.Threading; -using Microsoft.Build.BuildEngine; using Microsoft.Build.Framework; using NUnit.Framework; using Microsoft.Build.Utilities; diff --git a/msbuild/tests/Xamarin.iOS.Tasks.Tests/TestHelpers/TestBase.cs b/msbuild/tests/Xamarin.iOS.Tasks.Tests/TestHelpers/TestBase.cs index 6f01f2a3ee34..2983329f76cc 100644 --- a/msbuild/tests/Xamarin.iOS.Tasks.Tests/TestHelpers/TestBase.cs +++ b/msbuild/tests/Xamarin.iOS.Tasks.Tests/TestHelpers/TestBase.cs @@ -3,7 +3,8 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using Microsoft.Build.BuildEngine; +using Microsoft.Build.Evaluation; +using Microsoft.Build.Execution; using Microsoft.Build.Utilities; using NUnit.Framework; using Xamarin.MacDev; @@ -73,10 +74,18 @@ public Project LibraryProject { get; private set; } + public ProjectInstance LibraryProjectInstance { + get; set; + } + public Project MonoTouchProject { get; private set; } + public ProjectInstance MonoTouchProjectInstance { + get; set; + } + public string LibraryProjectBinPath; public string LibraryProjectObjPath; public string LibraryProjectPath; @@ -135,7 +144,9 @@ public virtual void Setup () SetupEngine (); MonoTouchProject = SetupProject (Engine, MonoTouchProjectCSProjPath); + MonoTouchProjectInstance = MonoTouchProject.CreateProjectInstance (); LibraryProject = SetupProject (Engine, LibraryProjectCSProjPath); + LibraryProjectInstance = LibraryProject.CreateProjectInstance (); CleanUp (); } @@ -145,12 +156,9 @@ public void SetupEngine () Engine = new TestEngine (); } - public Project SetupProject (Engine engine, string projectPath) + public Project SetupProject (TestEngine engine, string projectPath) { - var proj = new Project (engine); - proj.Load (projectPath); - - return proj; + return engine.ProjectCollection.LoadProject (projectPath); } public virtual string TargetFrameworkIdentifier { @@ -188,6 +196,9 @@ public void CleanUp () { File.SetLastWriteTimeUtc (file, DateTime.UtcNow); foreach (var file in Directory.GetFiles (LibraryProjectPath, "*.*", SearchOption.AllDirectories)) File.SetLastWriteTimeUtc (file, DateTime.UtcNow); + + Engine.UnloadAllProjects (); + Engine = new TestEngine (); } protected void SafeDelete (string path) @@ -293,8 +304,7 @@ protected DateTime GetLastModified (string file) protected void RemoveItemsByName (Project project, string itemName) { - foreach (var item in project.GetEvaluatedItemsByName (itemName).ToArray ()) - project.RemoveItem (item); + project.RemoveItems (project.GetItems (itemName)); } protected string SetPListKey (string key, PObject value) @@ -323,7 +333,12 @@ protected void Touch (string file) public void RunTarget (Project project, string target, int expectedErrorCount = 0) { - Engine.BuildProject (project, new [] { target }, new Hashtable { {"Platform", "iPhone"} }, BuildSettings.None); + RunTargetOnInstance (project.CreateProjectInstance (), target, expectedErrorCount); + } + + public void RunTargetOnInstance (ProjectInstance instance, string target, int expectedErrorCount = 0) + { + Engine.BuildProject (instance, new [] { target }, new Hashtable { {"Platform", "iPhone"} }); if (expectedErrorCount != Engine.Logger.ErrorEvents.Count) { string messages = string.Empty; if (Engine.Logger.ErrorEvents.Count > 0) { @@ -335,7 +350,12 @@ public void RunTarget (Project project, string target, int expectedErrorCount = public void RunTarget_WithErrors (Project project, string target) { - Engine.BuildProject (project, new [] { target }, new Hashtable (), BuildSettings.None); + RunTarget_WithErrors (project.CreateProjectInstance (), target); + } + + public void RunTarget_WithErrors (ProjectInstance instance, string target) + { + Engine.BuildProject (instance, new [] { target }, new Hashtable ()); Assert.IsTrue (Engine.Logger.ErrorEvents.Count > 0, "#RunTarget-HasExpectedErrors"); } diff --git a/msbuild/tests/Xamarin.iOS.Tasks.Tests/TestHelpers/TestEngine.cs b/msbuild/tests/Xamarin.iOS.Tasks.Tests/TestHelpers/TestEngine.cs index ddcbf69db26d..a75805752df8 100644 --- a/msbuild/tests/Xamarin.iOS.Tasks.Tests/TestHelpers/TestEngine.cs +++ b/msbuild/tests/Xamarin.iOS.Tasks.Tests/TestHelpers/TestEngine.cs @@ -5,35 +5,53 @@ using System.Runtime.Remoting; using System.Runtime.Serialization.Formatters.Binary; using System.Threading; -using Microsoft.Build.BuildEngine; using Microsoft.Build.Framework; +using Microsoft.Build.Evaluation; +using Microsoft.Build.Execution; +using Microsoft.Build.Logging; using NUnit.Framework; using Microsoft.Build.Utilities; namespace Xamarin.iOS.Tasks { - public class TestEngine : Engine, IBuildEngine + public class TestEngine : IBuildEngine { public Logger Logger { get; set; } - + public TestEngine () { Logger = new Logger (); + ProjectCollection = new ProjectCollection (); - RegisterLogger (Logger); + ProjectCollection.RegisterLogger (Logger); var printer = new ConsoleReportPrinter (); var cl = new ConsoleLogger (LoggerVerbosity.Diagnostic, printer.Print, printer.SetForeground, printer.ResetColor); - RegisterLogger (cl); + ProjectCollection.RegisterLogger (cl); } - public bool BuildProjectFile (string projectFileName, string[] targetNames, IDictionary globalProperties, IDictionary targetOutputs) + public bool BuildProjectFile (string projectFileName, string [] targetNames, IDictionary globalProperties, IDictionary targetOutputs) { throw new NotImplementedException (); } + + public bool BuildProject (ProjectInstance instance, string [] targetNames, IDictionary globalProperties) + { + if (globalProperties != null) { + foreach (DictionaryEntry de in globalProperties) { + //Note: trying to set this on the project causes the project to be added to the PC + // again, which of course, fails + instance.SetProperty ((string)de.Key, (string)de.Value); + } + } + + //FIXME: assumption that we are still using the same PC! + return instance.Build (targetNames, ProjectCollection.Loggers); + } + public void LogCustomEvent (CustomBuildEventArgs e) { Logger.CustomEvents.Add (e); @@ -51,6 +69,11 @@ public void LogWarningEvent (BuildWarningEventArgs e) Logger.WarningsEvents.Add (e); } + public void UnloadAllProjects () + { + ProjectCollection.UnloadAllProjects (); + } + public int ColumnNumberOfTaskNode { get { return 0; } } @@ -63,6 +86,8 @@ public int LineNumberOfTaskNode { public string ProjectFileOfTaskNode { get { return ""; } } + + public ProjectCollection ProjectCollection { get; set; } } } From 18f71688456f7ff9d2d9b2f88d55575e8f385550 Mon Sep 17 00:00:00 2001 From: Ankit Date: Mon, 21 May 2018 18:42:37 -0400 Subject: [PATCH 04/23] [tests] Fix DetectAppManifest_ExecutableProject_NoPList `ProjectInstance.GetPropertyValue` returns empty string if the property doesn't exist. https://docs.microsoft.com/en-us/dotnet/api/microsoft.build.execution.projectinstance.getpropertyvalue?view=netframework-4.7.2#Microsoft_Build_Execution_ProjectInstance_GetPropertyValue_System_String_ --- .../tests/Xamarin.iOS.Tasks.Tests/TargetTests/TargetTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/msbuild/tests/Xamarin.iOS.Tasks.Tests/TargetTests/TargetTests.cs b/msbuild/tests/Xamarin.iOS.Tasks.Tests/TargetTests/TargetTests.cs index f22df5697988..41f69d1821f2 100644 --- a/msbuild/tests/Xamarin.iOS.Tasks.Tests/TargetTests/TargetTests.cs +++ b/msbuild/tests/Xamarin.iOS.Tasks.Tests/TargetTests/TargetTests.cs @@ -557,7 +557,7 @@ public void DetectAppManifest_ExecutableProject_NoPList () MonoTouchProjectInstance = MonoTouchProject.CreateProjectInstance (); RunTarget_WithErrors (MonoTouchProjectInstance, TargetName.DetectAppManifest); - Assert.IsNull (MonoTouchProjectInstance.GetPropertyValue ("_AppManifest"), "#1"); + Assert.IsNullOrEmpty (MonoTouchProjectInstance.GetPropertyValue ("_AppManifest"), "#1"); } [Test] From 2805beaf63ef445d5657ffd50f8342a397b1cf5f Mon Sep 17 00:00:00 2001 From: Ankit Date: Mon, 21 May 2018 18:53:24 -0400 Subject: [PATCH 05/23] [tests] Ensure that the correct msbuild.dll.config gets picked up .. by setting `MSBUILD_EXE_PATH` to the corresponding `MSBuild.dll`. --- tests/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/Makefile b/tests/Makefile index d485a41495f8..a830dccc0ac8 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -41,6 +41,7 @@ EXEC_UNIT_SERVER=XCODE_DEVELOPER_ROOT=$(XCODE_DEVELOPER_ROOT) MONOTOUCH_ROOT=$(I export MD_APPLE_SDK_ROOT=$(abspath $(XCODE_DEVELOPER_ROOT)/../..) export MD_MTOUCH_SDK_ROOT=$(IOS_DESTDIR)/$(MONOTOUCH_PREFIX) +export MSBUILD_EXE_PATH=$(MONO_PREFIX)/lib/mono/msbuild/15.0/bin/MSBuild.dll export TargetFrameworkFallbackSearchPaths=$(IOS_DESTDIR)/Library/Frameworks/Mono.framework/External/xbuild-frameworks export MSBuildExtensionsPathFallbackPathsOverride=$(IOS_DESTDIR)/Library/Frameworks/Mono.framework/External/xbuild export XAMMAC_FRAMEWORK_PATH=$(MAC_DESTDIR)/Library/Frameworks/Xamarin.Mac.framework/Versions/Current From b883c4fe42bb5820b6496f7078a54ef46c416630 Mon Sep 17 00:00:00 2001 From: Ankit Date: Mon, 21 May 2018 18:54:57 -0400 Subject: [PATCH 06/23] [tests] Don't use WriteLine in TestHelpers.Loggers as msbuild adds that .. itself. --- msbuild/tests/Xamarin.iOS.Tasks.Tests/TestHelpers/Logger.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/msbuild/tests/Xamarin.iOS.Tasks.Tests/TestHelpers/Logger.cs b/msbuild/tests/Xamarin.iOS.Tasks.Tests/TestHelpers/Logger.cs index 161f30a7ea61..65489e78ba67 100644 --- a/msbuild/tests/Xamarin.iOS.Tasks.Tests/TestHelpers/Logger.cs +++ b/msbuild/tests/Xamarin.iOS.Tasks.Tests/TestHelpers/Logger.cs @@ -192,7 +192,7 @@ string FormatText (string txt) public void Print (string message) { - writer.WriteLine (FormatText (message)); + writer.Write (FormatText (message)); } } From 9e53fd5345037c2f25eeb244b603d3a2f1844b49 Mon Sep 17 00:00:00 2001 From: Ankit Date: Thu, 17 May 2018 15:23:39 -0400 Subject: [PATCH 07/23] [tests] Xamarin.iOS.Tasks.TargetTests.RebuildExecutable_TouchLibraryDll msbuild just copies the output assembly from obj to bin. So, the test needs to `touch` the file in `obj` to trigger a rebuild. --- .../tests/Xamarin.iOS.Tasks.Tests/TargetTests/TargetTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/msbuild/tests/Xamarin.iOS.Tasks.Tests/TargetTests/TargetTests.cs b/msbuild/tests/Xamarin.iOS.Tasks.Tests/TargetTests/TargetTests.cs index 41f69d1821f2..045bc06e980a 100644 --- a/msbuild/tests/Xamarin.iOS.Tasks.Tests/TargetTests/TargetTests.cs +++ b/msbuild/tests/Xamarin.iOS.Tasks.Tests/TargetTests/TargetTests.cs @@ -288,7 +288,7 @@ public void RebuildExecutable_TouchLibraryDll () RunTarget (MonoTouchProject, TargetName.Build); var timestamps = ExpectedExecutableFiles.ToDictionary (file => file, file => GetLastModified (file)); - Touch (Path.Combine (LibraryProjectBinPath, "MyLibrary.dll")); + Touch (Path.Combine (LibraryProjectObjPath, "MyLibrary.dll")); RunTarget (MonoTouchProject, TargetName.Build); var newTimestamps = ExpectedExecutableFiles.ToDictionary (file => file, file => GetLastModified (file)); From 6fc89ab660750261bb785185557c3a45e6ee4a76 Mon Sep 17 00:00:00 2001 From: Ankit Date: Thu, 17 May 2018 16:12:38 -0400 Subject: [PATCH 08/23] [tests] msbuild-mac Fix tests depending on msbuild specific strings Xamarin.MMP.Tests.MMPTests.BuildingSameBindingProject_TwoTimes_ShallNotInvokeMMPTwoTimes Xamarin.MMP.Tests.MMPTests.BuildingSameProject_TwoTimes_ShallNotInvokeMMPTwoTimes --- tests/msbuild-mac/src/MSBuild-Smoke.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/msbuild-mac/src/MSBuild-Smoke.cs b/tests/msbuild-mac/src/MSBuild-Smoke.cs index 5c531dc607d1..82f77ff1751e 100644 --- a/tests/msbuild-mac/src/MSBuild-Smoke.cs +++ b/tests/msbuild-mac/src/MSBuild-Smoke.cs @@ -164,10 +164,10 @@ public void BuildingSameBindingProject_TwoTimes_ShallNotInvokeMMPTwoTimes () var config = new TI.UnifiedTestConfig (tmpDir) { ProjectName = project, ItemGroup = nativeRefItemGroup }; string projectPath = TI.GenerateBindingLibraryProject (config); string buildOutput = TI.BuildProject (projectPath, isUnified: true, diagnosticMSBuild: true); - Assert.IsTrue (buildOutput.Contains ("Target CoreCompile needs to be built")); + Assert.IsTrue (buildOutput.Contains (@"Building target ""CoreCompile""")); string secondBuildOutput = TI.BuildProject (projectPath, isUnified: true, diagnosticMSBuild: true); - Assert.IsFalse (secondBuildOutput.Contains ("Target CoreCompile needs to be built")); + Assert.IsFalse (secondBuildOutput.Contains (@"Building target ""CoreCompile""")); } }); } @@ -182,10 +182,10 @@ public void BuildingSameProject_TwoTimes_ShallNotInvokeMMPTwoTimes () var config = new TI.UnifiedTestConfig (tmpDir) { ProjectName = project }; string projectPath = TI.GenerateEXEProject (config); string buildOutput = TI.BuildProject (projectPath, isUnified: true, diagnosticMSBuild: true); - Assert.IsTrue (buildOutput.Contains ("Target _CompileToNative needs to be built")); + Assert.IsTrue (buildOutput.Contains (@"Building target ""_CompileToNative""")); string secondBuildOutput = TI.BuildProject (projectPath, isUnified: true, diagnosticMSBuild: true); - Assert.IsFalse (secondBuildOutput.Contains ("Target _CompileToNative needs to be built")); + Assert.IsFalse (secondBuildOutput.Contains (@"Building target ""_CompileToNative""")); } }); } From 26abe1badc06a58794c47a83aca2be996940719a Mon Sep 17 00:00:00 2001 From: Ankit Date: Thu, 17 May 2018 17:38:11 -0400 Subject: [PATCH 09/23] [tests] Fix tests that depend on tool output Lot of tests depend on comparing text in tool output. In xbuild, this was logged with `MessageImportance.Normal` but in msbuild the default is `MessageImportance.Low`. So, now the tool output doesn't show up in the normal verbosity log, causing the build to fail. Due to the number of tests depending on this, the default is changed to `diagnosticMSBuild = true`. A better way would probably (future) be to use a custom logger and get the output from the logging events. --- tests/common/mac/ProjectTestHelpers.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/common/mac/ProjectTestHelpers.cs b/tests/common/mac/ProjectTestHelpers.cs index cee161edb719..09c3dcd0989d 100644 --- a/tests/common/mac/ProjectTestHelpers.cs +++ b/tests/common/mac/ProjectTestHelpers.cs @@ -167,6 +167,7 @@ public class UnifiedTestConfig public UnifiedTestConfig (string tmpDir) { TmpDir = tmpDir; + DiagnosticMSBuild = true; } } From 8f0df143a12b84d04a9326e6c8e5770c7de4498d Mon Sep 17 00:00:00 2001 From: Ankit Date: Fri, 18 May 2018 18:23:29 -0400 Subject: [PATCH 10/23] [tests] Remove project path at the end of errors/warnings before comparing - msbuild adds project path at the end of errors/warnings, which xbuild didn't do. This caused two tests to fail: Xamarin.MMP.Tests.MMPTests.MM0132("inline-runtime-arch") Xamarin.MMP.Tests.MMPTests.MM0132("foo") --- tests/common/ExecutionHelper.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/common/ExecutionHelper.cs b/tests/common/ExecutionHelper.cs index 7cb576acd048..617bbae65709 100644 --- a/tests/common/ExecutionHelper.cs +++ b/tests/common/ExecutionHelper.cs @@ -108,6 +108,23 @@ bool IndexOfAny (string line, out int start, out int end, params string [] value return false; } + string RemovePathAtEnd (string line) + { + if (line.TrimEnd ().EndsWith ("]")) { + var start = line.LastIndexOf ("["); + if (start >= 0) { + // we want to get the space before `[` too. + if (start > 0 && line [start - 1] == ' ') + start --; + + line = line.Substring (0, start); + return line; + } + } + + return line; + } + public void ParseMessages () { messages.Clear (); @@ -120,9 +137,11 @@ public void ParseMessages () msg.IsError = true; origin = line.Substring (0, idxError); line = line.Substring (endError); + line = RemovePathAtEnd (line); } else if (IndexOfAny (line, out var idxWarning, out var endWarning, ": warning ", ": warning ")) { origin = line.Substring (0, idxWarning); line = line.Substring (endWarning); + line = RemovePathAtEnd (line); } else if (line.StartsWith ("error ", StringComparison.Ordinal)) { msg.IsError = true; line = line.Substring (6); From 6278f108cfd1c1cd7b1d74319b55cfdf56801960 Mon Sep 17 00:00:00 2001 From: Ankit Date: Fri, 18 May 2018 18:29:10 -0400 Subject: [PATCH 11/23] [tests] Remove `bool useMSBuild` arg from ProjectTestHelpers .. as we always use msbuild now. --- tests/common/mac/ProjectTestHelpers.cs | 14 +++++++------- tests/mmptest/src/MMPTest.cs | 2 +- tests/mmptest/src/NetStandardTests.cs | 4 ++-- tests/msbuild-mac/src/RoslynSmokeTests.cs | 4 ++-- tests/msbuild-mac/src/RuntimeTests.cs | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/tests/common/mac/ProjectTestHelpers.cs b/tests/common/mac/ProjectTestHelpers.cs index 09c3dcd0989d..09a097f7b36a 100644 --- a/tests/common/mac/ProjectTestHelpers.cs +++ b/tests/common/mac/ProjectTestHelpers.cs @@ -224,12 +224,12 @@ public static string RunAndAssert (string exe, StringBuilder args, string stepNa } // In most cases we generate projects in tmp and this is not needed. But nuget and test projects can make that hard - public static void CleanUnifiedProject (string csprojTarget, bool useMSBuild = false) + public static void CleanUnifiedProject (string csprojTarget) { - RunAndAssert ("/Library/Frameworks/Mono.framework/Commands/" + (useMSBuild ? "msbuild" : "msbuild"), new StringBuilder (csprojTarget + " /t:clean"), "Clean"); + RunAndAssert ("/Library/Frameworks/Mono.framework/Commands/msbuild", new StringBuilder (csprojTarget + " /t:clean"), "Clean"); } - public static string BuildProject (string csprojTarget, bool isUnified, bool diagnosticMSBuild = false, bool shouldFail = false, bool useMSBuild = false, bool release = false, string[] environment = null) + public static string BuildProject (string csprojTarget, bool isUnified, bool diagnosticMSBuild = false, bool shouldFail = false, bool release = false, string[] environment = null) { string rootDirectory = FindRootDirectory (); @@ -375,10 +375,10 @@ public static string GenerateUnifiedExecutableProject (UnifiedTestConfig config) return GenerateEXEProject (config); } - public static string GenerateAndBuildUnifiedExecutable (UnifiedTestConfig config, bool shouldFail = false, bool useMSBuild = false, string[] environment = null) + public static string GenerateAndBuildUnifiedExecutable (UnifiedTestConfig config, bool shouldFail = false, string[] environment = null) { string csprojTarget = GenerateUnifiedExecutableProject (config); - return BuildProject (csprojTarget, isUnified: true, diagnosticMSBuild: config.DiagnosticMSBuild, shouldFail: shouldFail, useMSBuild: useMSBuild, release: config.Release, environment: environment); + return BuildProject (csprojTarget, isUnified: true, diagnosticMSBuild: config.DiagnosticMSBuild, shouldFail: shouldFail, release: config.Release, environment: environment); } public static string RunGeneratedUnifiedExecutable (UnifiedTestConfig config) @@ -388,7 +388,7 @@ public static string RunGeneratedUnifiedExecutable (UnifiedTestConfig config) return RunEXEAndVerifyGUID (config.TmpDir, config.guid, exePath); } - public static OutputText TestUnifiedExecutable (UnifiedTestConfig config, bool shouldFail = false, bool useMSBuild = false, string[] environment = null) + public static OutputText TestUnifiedExecutable (UnifiedTestConfig config, bool shouldFail = false, string[] environment = null) { // If we've already generated guid bits for this config, don't tack on a second copy if (config.guid == Guid.Empty) @@ -397,7 +397,7 @@ public static OutputText TestUnifiedExecutable (UnifiedTestConfig config, bool s config.TestCode += GenerateOutputCommand (config.TmpDir, config.guid); } - string buildOutput = GenerateAndBuildUnifiedExecutable (config, shouldFail, useMSBuild, environment); + string buildOutput = GenerateAndBuildUnifiedExecutable (config, shouldFail, environment); if (shouldFail) return new OutputText (buildOutput, ""); diff --git a/tests/mmptest/src/MMPTest.cs b/tests/mmptest/src/MMPTest.cs index 9c52c7341daa..91e2b2672849 100644 --- a/tests/mmptest/src/MMPTest.cs +++ b/tests/mmptest/src/MMPTest.cs @@ -357,7 +357,7 @@ public void Unified_FailedBuild_ShouldRequireAnotherBuildNotSkipMMP () // If we fail, we'll likley fail with "did not generate an exe" before returning but let's check anyway string secondBuildOutput = TI.BuildProject (Path.Combine (tmpDir, TI.GetUnifiedExecutableProjectName (test)), true, diagnosticMSBuild: true); Assert.IsTrue (!secondBuildOutput.Contains ("Skipping target \"_CompileToNative"), "Did not skip"); - Assert.IsTrue (secondBuildOutput.Contains ("CompileToNative needs to be built as output file"), "Did need to build"); + Assert.IsTrue (secondBuildOutput.Contains ("Building target \"_CompileToNative\" completely"), "Did need to build"); } }); } diff --git a/tests/mmptest/src/NetStandardTests.cs b/tests/mmptest/src/NetStandardTests.cs index 70d07c6f340f..fa972b95390b 100644 --- a/tests/mmptest/src/NetStandardTests.cs +++ b/tests/mmptest/src/NetStandardTests.cs @@ -31,7 +31,7 @@ static void NetStandardTestCore (string tmpDir, bool full) string netStandardProject = TI.GenerateNetStandardProject (config); TI.RunAndAssert("/usr/local/share/dotnet/dotnet", $"restore {netStandardProject}", "Restore"); - TI.BuildProject(netStandardProject, true, useMSBuild: true); + TI.BuildProject(netStandardProject, true); config.ItemGroup = $@" @@ -49,7 +49,7 @@ static void NetStandardTestCore (string tmpDir, bool full) config.CSProjConfig = "--registrar=dynamic"; config.XM45 = full; - TI.TestUnifiedExecutable(config, useMSBuild: true); + TI.TestUnifiedExecutable(config); } } } diff --git a/tests/msbuild-mac/src/RoslynSmokeTests.cs b/tests/msbuild-mac/src/RoslynSmokeTests.cs index 71f5e7d93793..6b81270313f8 100644 --- a/tests/msbuild-mac/src/RoslynSmokeTests.cs +++ b/tests/msbuild-mac/src/RoslynSmokeTests.cs @@ -26,7 +26,7 @@ public void XMModernRosylnProjet_ShouldBuildAndRunWithMSBuild () TI.CleanUnifiedProject (projectPath); RestoreRoslynNuget ("Modern"); - TI.BuildProject (projectPath, true, useMSBuild: true); + TI.BuildProject (projectPath, true); TI.RunAndAssert (Path.Combine (RoslynTestProjectRoot, "Modern/bin/Debug/RoslynTestApp.app/Contents/MacOS/RoslynTestApp"), new StringBuilder (), "Run"); } @@ -37,7 +37,7 @@ public void XMFullRosylnProjet_ShouldBuildAndRunWithMSBuild () TI.CleanUnifiedProject (projectPath); RestoreRoslynNuget ("Full"); - TI.BuildProject (projectPath, true, useMSBuild: true); + TI.BuildProject (projectPath, true); TI.RunAndAssert (Path.Combine (RoslynTestProjectRoot, "Full/bin/Debug/RoslynTestApp.app/Contents/MacOS/RoslynTestApp"), new StringBuilder (), "Run"); } } diff --git a/tests/msbuild-mac/src/RuntimeTests.cs b/tests/msbuild-mac/src/RuntimeTests.cs index 8f09dfd61d27..f0a1a370c983 100644 --- a/tests/msbuild-mac/src/RuntimeTests.cs +++ b/tests/msbuild-mac/src/RuntimeTests.cs @@ -18,7 +18,7 @@ public void AssemblyRegistration () var projectPath = Path.Combine (TestProjectRoot, projectName, $"{projectName}.csproj"); TI.CleanUnifiedProject (projectPath); - TI.BuildProject (projectPath, true, useMSBuild: false); + TI.BuildProject (projectPath, true); TI.RunAndAssert (Path.Combine (Path.GetDirectoryName (projectPath), $"bin/Debug/{projectName}.app/Contents/MacOS/{projectName}"), new StringBuilder (), "Run"); } } From b578593a15a9e49fe79f6b37d91b68ef5b57e8cf Mon Sep 17 00:00:00 2001 From: Ankit Date: Tue, 22 May 2018 14:17:31 -0400 Subject: [PATCH 12/23] [tests] Remove TI.UnifiedTestConfig.DiagnosticMSBuild .. as we always build with diagnostic verbosity now. And remove the parameter from `TI.BuildProject(..)`. --- tests/common/mac/ProjectTestHelpers.cs | 12 +++++------- tests/mmptest/src/MMPTest.cs | 2 +- tests/msbuild-mac/src/MSBuild-Smoke.cs | 8 ++++---- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/tests/common/mac/ProjectTestHelpers.cs b/tests/common/mac/ProjectTestHelpers.cs index 09a097f7b36a..147d60a27338 100644 --- a/tests/common/mac/ProjectTestHelpers.cs +++ b/tests/common/mac/ProjectTestHelpers.cs @@ -141,7 +141,6 @@ public class UnifiedTestConfig // Not necessarly required public bool FSharp { get; set; } public bool XM45 { get; set; } - public bool DiagnosticMSBuild { get; set; } public bool Release { get; set; } = false; public string ProjectName { get; set; } = ""; @@ -167,7 +166,6 @@ public class UnifiedTestConfig public UnifiedTestConfig (string tmpDir) { TmpDir = tmpDir; - DiagnosticMSBuild = true; } } @@ -229,7 +227,7 @@ public static void CleanUnifiedProject (string csprojTarget) RunAndAssert ("/Library/Frameworks/Mono.framework/Commands/msbuild", new StringBuilder (csprojTarget + " /t:clean"), "Clean"); } - public static string BuildProject (string csprojTarget, bool isUnified, bool diagnosticMSBuild = false, bool shouldFail = false, bool release = false, string[] environment = null) + public static string BuildProject (string csprojTarget, bool isUnified, bool shouldFail = false, bool release = false, string[] environment = null) { string rootDirectory = FindRootDirectory (); @@ -242,7 +240,7 @@ public static string BuildProject (string csprojTarget, bool isUnified, bool dia // This is to force build to use our mmp and not system mmp StringBuilder buildArgs = new StringBuilder (); if (isUnified) { - buildArgs.Append (diagnosticMSBuild ? " /verbosity:diagnostic " : " /verbosity:normal "); + buildArgs.Append (" /verbosity:diagnostic "); buildArgs.Append (" /property:XamarinMacFrameworkRoot=" + rootDirectory + "/Library/Frameworks/Xamarin.Mac.framework/Versions/Current "); if (release) @@ -378,7 +376,7 @@ public static string GenerateUnifiedExecutableProject (UnifiedTestConfig config) public static string GenerateAndBuildUnifiedExecutable (UnifiedTestConfig config, bool shouldFail = false, string[] environment = null) { string csprojTarget = GenerateUnifiedExecutableProject (config); - return BuildProject (csprojTarget, isUnified: true, diagnosticMSBuild: config.DiagnosticMSBuild, shouldFail: shouldFail, release: config.Release, environment: environment); + return BuildProject (csprojTarget, isUnified: true, shouldFail: shouldFail, release: config.Release, environment: environment); } public static string RunGeneratedUnifiedExecutable (UnifiedTestConfig config) @@ -410,7 +408,7 @@ public static OutputText TestClassicExecutable (string tmpDir, string testCode = { Guid guid = Guid.NewGuid (); string csprojTarget = GenerateClassicEXEProject (tmpDir, "ClassicExample.csproj", testCode + GenerateOutputCommand (tmpDir,guid), csprojConfig, includeMonoRuntime: includeMonoRuntime); - string buildOutput = BuildProject (csprojTarget, isUnified : false, diagnosticMSBuild: false, shouldFail : shouldFail); + string buildOutput = BuildProject (csprojTarget, isUnified : false, shouldFail : shouldFail); if (shouldFail) return new OutputText (buildOutput, ""); @@ -427,7 +425,7 @@ public static OutputText TestSystemMonoExecutable (UnifiedTestConfig config, boo config.ProjectName = $"{projectName}.csproj"; string csprojTarget = GenerateSystemMonoEXEProject (config); - string buildOutput = BuildProject (csprojTarget, isUnified: true, diagnosticMSBuild: config.DiagnosticMSBuild, shouldFail: shouldFail, release: config.Release); + string buildOutput = BuildProject (csprojTarget, isUnified: true, shouldFail: shouldFail, release: config.Release); if (shouldFail) return new OutputText (buildOutput, ""); diff --git a/tests/mmptest/src/MMPTest.cs b/tests/mmptest/src/MMPTest.cs index 91e2b2672849..cbd61716e562 100644 --- a/tests/mmptest/src/MMPTest.cs +++ b/tests/mmptest/src/MMPTest.cs @@ -355,7 +355,7 @@ public void Unified_FailedBuild_ShouldRequireAnotherBuildNotSkipMMP () // And try again. // If we fail, we'll likley fail with "did not generate an exe" before returning but let's check anyway - string secondBuildOutput = TI.BuildProject (Path.Combine (tmpDir, TI.GetUnifiedExecutableProjectName (test)), true, diagnosticMSBuild: true); + string secondBuildOutput = TI.BuildProject (Path.Combine (tmpDir, TI.GetUnifiedExecutableProjectName (test)), true); Assert.IsTrue (!secondBuildOutput.Contains ("Skipping target \"_CompileToNative"), "Did not skip"); Assert.IsTrue (secondBuildOutput.Contains ("Building target \"_CompileToNative\" completely"), "Did need to build"); } diff --git a/tests/msbuild-mac/src/MSBuild-Smoke.cs b/tests/msbuild-mac/src/MSBuild-Smoke.cs index 82f77ff1751e..da02bd5670f1 100644 --- a/tests/msbuild-mac/src/MSBuild-Smoke.cs +++ b/tests/msbuild-mac/src/MSBuild-Smoke.cs @@ -163,10 +163,10 @@ public void BuildingSameBindingProject_TwoTimes_ShallNotInvokeMMPTwoTimes () { var config = new TI.UnifiedTestConfig (tmpDir) { ProjectName = project, ItemGroup = nativeRefItemGroup }; string projectPath = TI.GenerateBindingLibraryProject (config); - string buildOutput = TI.BuildProject (projectPath, isUnified: true, diagnosticMSBuild: true); + string buildOutput = TI.BuildProject (projectPath, isUnified: true); Assert.IsTrue (buildOutput.Contains (@"Building target ""CoreCompile""")); - string secondBuildOutput = TI.BuildProject (projectPath, isUnified: true, diagnosticMSBuild: true); + string secondBuildOutput = TI.BuildProject (projectPath, isUnified: true); Assert.IsFalse (secondBuildOutput.Contains (@"Building target ""CoreCompile""")); } }); @@ -181,10 +181,10 @@ public void BuildingSameProject_TwoTimes_ShallNotInvokeMMPTwoTimes () { var config = new TI.UnifiedTestConfig (tmpDir) { ProjectName = project }; string projectPath = TI.GenerateEXEProject (config); - string buildOutput = TI.BuildProject (projectPath, isUnified: true, diagnosticMSBuild: true); + string buildOutput = TI.BuildProject (projectPath, isUnified: true); Assert.IsTrue (buildOutput.Contains (@"Building target ""_CompileToNative""")); - string secondBuildOutput = TI.BuildProject (projectPath, isUnified: true, diagnosticMSBuild: true); + string secondBuildOutput = TI.BuildProject (projectPath, isUnified: true); Assert.IsFalse (secondBuildOutput.Contains (@"Building target ""_CompileToNative""")); } }); From 526f009e6413f9e3146a8b87941864fc481d0e21 Mon Sep 17 00:00:00 2001 From: Ankit Date: Mon, 21 May 2018 16:13:11 -0400 Subject: [PATCH 13/23] [tests] Fix Xamarin.iOS.Tasks.TargetTests.GenerateBundleName_ExecutableProject msbuild has the path in it's original form (with windows slashes). ``` Test Failure : Xamarin.iOS.Tasks.TargetTests.GenerateBundleName_ExecutableProject #3 String lengths are both 42. Strings differ at index 3. Expected: "bin/iPhoneSimulator/Debug/MySingleView.app" But was: "bin\\iPhoneSimulator\\Debug\\MySingleView.app" --------------^ at Xamarin.iOS.Tasks.TargetTests.GenerateBundleName_ExecutableProject () [0x00054] in /Users/ankit/dev/xamarin-macios/msbuild/tests/Xamarin.iOS.Tasks.Tests/TargetTests/TargetTests.cs:394 ``` --- .../tests/Xamarin.iOS.Tasks.Tests/TargetTests/TargetTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/msbuild/tests/Xamarin.iOS.Tasks.Tests/TargetTests/TargetTests.cs b/msbuild/tests/Xamarin.iOS.Tasks.Tests/TargetTests/TargetTests.cs index 045bc06e980a..d75500f495eb 100644 --- a/msbuild/tests/Xamarin.iOS.Tasks.Tests/TargetTests/TargetTests.cs +++ b/msbuild/tests/Xamarin.iOS.Tasks.Tests/TargetTests/TargetTests.cs @@ -391,7 +391,7 @@ public void GenerateBundleName_ExecutableProject () // Now we should have an AppBundleDir RunTargetOnInstance (MonoTouchProjectInstance, TargetName.GenerateBundleName); - Assert.AreEqual ("bin/iPhoneSimulator/Debug/MySingleView.app", MonoTouchProjectInstance.GetPropertyValue ("AppBundleDir"), "#3"); + Assert.AreEqual (@"bin\iPhoneSimulator\Debug\MySingleView.app", MonoTouchProjectInstance.GetPropertyValue ("AppBundleDir"), "#3"); } [Test] From 16e512af5dbe4465f4d93cb5bea7d5e22f7a19c1 Mon Sep 17 00:00:00 2001 From: Ankit Date: Mon, 21 May 2018 19:42:30 -0400 Subject: [PATCH 14/23] Revert "[msbuild] Add forward compatibility with symlinks support (#648)" This can be reverted as we have now moved to msbuild assemblies, and they already have this property. This reverts commit d45f52f1c1101d5821e00797ba30d21bcef8bc32. --- msbuild/Xamarin.MacDev.Tasks.Core/MsBuildTasks/CopyBase.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/msbuild/Xamarin.MacDev.Tasks.Core/MsBuildTasks/CopyBase.cs b/msbuild/Xamarin.MacDev.Tasks.Core/MsBuildTasks/CopyBase.cs index 82cd294c4439..69ebc90f00f3 100644 --- a/msbuild/Xamarin.MacDev.Tasks.Core/MsBuildTasks/CopyBase.cs +++ b/msbuild/Xamarin.MacDev.Tasks.Core/MsBuildTasks/CopyBase.cs @@ -3,6 +3,5 @@ public abstract class CopyBase : Copy { public string SessionId { get; set; } - public bool UseSymboliclinksIfPossible { get; set; } } } From 19d9a64d02c35ab84792b52ef81893f37e4abea4 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Fri, 27 Jul 2018 11:40:53 +0200 Subject: [PATCH 15/23] [xharness] Don't add LogicalName beneath Import elements, it doesn't work with MSBuild. --- tests/xharness/ProjectFileExtensions.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/xharness/ProjectFileExtensions.cs b/tests/xharness/ProjectFileExtensions.cs index 5c932099bd60..4feda9e9b6a2 100644 --- a/tests/xharness/ProjectFileExtensions.cs +++ b/tests/xharness/ProjectFileExtensions.cs @@ -796,7 +796,6 @@ public static void ResolveAllPaths (this XmlDocument csproj, string project_path new string [] { "ObjcBindingCoreSource", "Include" }, new string [] { "ObjcBindingNativeLibrary", "Include" }, new string [] { "ObjcBindingNativeFramework", "Include" }, - new string [] { "Import", "Project" }, new string [] { "FilesToCopy", "Include" }, new string [] { "FilesToCopyFoo", "Include" }, new string [] { "FilesToCopyFooBar", "Include" }, From afcad3b4baa27df3dc5fba67bca1576ee8285e2f Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Fri, 27 Jul 2018 11:41:23 +0200 Subject: [PATCH 16/23] [xharness] Set the right variable to point msbuild to our locally built xbuild targets. --- tests/xharness/Jenkins.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/xharness/Jenkins.cs b/tests/xharness/Jenkins.cs index 2d5287011f04..d2fd8c4f142f 100644 --- a/tests/xharness/Jenkins.cs +++ b/tests/xharness/Jenkins.cs @@ -2416,7 +2416,7 @@ protected void SetEnvironmentVariables (Process process) process.StartInfo.EnvironmentVariables ["MD_APPLE_SDK_ROOT"] = Harness.XcodeRoot; process.StartInfo.EnvironmentVariables ["MD_MTOUCH_SDK_ROOT"] = Path.Combine (Harness.IOS_DESTDIR, "Library", "Frameworks", "Xamarin.iOS.framework", "Versions", "Current"); process.StartInfo.EnvironmentVariables ["TargetFrameworkFallbackSearchPaths"] = Path.Combine (Harness.IOS_DESTDIR, "Library", "Frameworks", "Mono.framework", "External", "xbuild-frameworks"); - process.StartInfo.EnvironmentVariables ["MSBuildExtensionsPath"] = Path.Combine (Harness.IOS_DESTDIR, "Library", "Frameworks", "Mono.framework", "External", "xbuild"); + process.StartInfo.EnvironmentVariables ["MSBuildExtensionsPathFallbackPathsOverride"] = Path.Combine (Harness.IOS_DESTDIR, "Library", "Frameworks", "Mono.framework", "External", "xbuild"); break; case TestPlatform.Mac: case TestPlatform.Mac_Classic: @@ -2426,7 +2426,7 @@ protected void SetEnvironmentVariables (Process process) case TestPlatform.Mac_UnifiedXM45_32: process.StartInfo.EnvironmentVariables ["MD_APPLE_SDK_ROOT"] = Harness.XcodeRoot; process.StartInfo.EnvironmentVariables ["TargetFrameworkFallbackSearchPaths"] = Path.Combine (Harness.MAC_DESTDIR, "Library", "Frameworks", "Mono.framework", "External", "xbuild-frameworks"); - process.StartInfo.EnvironmentVariables ["MSBuildExtensionsPath"] = Path.Combine (Harness.MAC_DESTDIR, "Library", "Frameworks", "Mono.framework", "External", "xbuild"); + process.StartInfo.EnvironmentVariables ["MSBuildExtensionsPathFallbackPathsOverride"] = Path.Combine (Harness.MAC_DESTDIR, "Library", "Frameworks", "Mono.framework", "External", "xbuild"); process.StartInfo.EnvironmentVariables ["XamarinMacFrameworkRoot"] = Path.Combine (Harness.MAC_DESTDIR, "Library", "Frameworks", "Xamarin.Mac.framework", "Versions", "Current"); process.StartInfo.EnvironmentVariables ["XAMMAC_FRAMEWORK_PATH"] = Path.Combine (Harness.MAC_DESTDIR, "Library", "Frameworks", "Xamarin.Mac.framework", "Versions", "Current"); break; From 50e05547aace7348dcd3c10bfbb379936f026506 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Fri, 27 Jul 2018 17:40:29 +0200 Subject: [PATCH 17/23] [xharness] Process Import elements, but don't add LogicalName to them. --- tests/xharness/ProjectFileExtensions.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/tests/xharness/ProjectFileExtensions.cs b/tests/xharness/ProjectFileExtensions.cs index 4feda9e9b6a2..ff72f51155e0 100644 --- a/tests/xharness/ProjectFileExtensions.cs +++ b/tests/xharness/ProjectFileExtensions.cs @@ -796,6 +796,7 @@ public static void ResolveAllPaths (this XmlDocument csproj, string project_path new string [] { "ObjcBindingCoreSource", "Include" }, new string [] { "ObjcBindingNativeLibrary", "Include" }, new string [] { "ObjcBindingNativeFramework", "Include" }, + new string [] { "Import", "Project", "CustomBuildActions.targets", "../SyncTestResources.targets" }, new string [] { "FilesToCopy", "Include" }, new string [] { "FilesToCopyFoo", "Include" }, new string [] { "FilesToCopyFooBar", "Include" }, @@ -843,10 +844,22 @@ public static void ResolveAllPaths (this XmlDocument csproj, string project_path var a = node.Attributes [attrib]; if (a == null) continue; + + // entries after index 2 is a list of values to filter the attribute value against. + var found = kvp.Length == 2; + var skipLogicalName = kvp.Length > 2; + for (var i = 2; i < kvp.Length; i++) { + if (a.Value.Contains ("Sync")) + Console.WriteLine ("STOP"); + found |= a.Value == kvp [i]; + } + if (!found) + continue; + // Fix any default LogicalName values (but don't change existing ones). var ln = node.SelectElementNodes ("LogicalName")?.SingleOrDefault (); var links = node.SelectElementNodes ("Link"); - if (ln == null && !links.Any ()) { + if (!skipLogicalName && ln == null && !links.Any ()) { ln = csproj.CreateElement ("LogicalName", MSBuild_Namespace); node.AppendChild (ln); From 06d74108af2529f878bcb036d3aa006d481a4643 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Fri, 27 Jul 2018 17:40:29 +0200 Subject: [PATCH 18/23] Remove debug spew. --- tests/xharness/ProjectFileExtensions.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/xharness/ProjectFileExtensions.cs b/tests/xharness/ProjectFileExtensions.cs index ff72f51155e0..970e9331a506 100644 --- a/tests/xharness/ProjectFileExtensions.cs +++ b/tests/xharness/ProjectFileExtensions.cs @@ -848,11 +848,8 @@ public static void ResolveAllPaths (this XmlDocument csproj, string project_path // entries after index 2 is a list of values to filter the attribute value against. var found = kvp.Length == 2; var skipLogicalName = kvp.Length > 2; - for (var i = 2; i < kvp.Length; i++) { - if (a.Value.Contains ("Sync")) - Console.WriteLine ("STOP"); + for (var i = 2; i < kvp.Length; i++) found |= a.Value == kvp [i]; - } if (!found) continue; From 2e75028fc00367260b45e545b56b06f5d635a6b8 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Mon, 30 Jul 2018 16:00:55 +0200 Subject: [PATCH 19/23] [tests] Set XamarinMacFrameworkRoot as an environment variable when running MSBuild tests. Set XamarinMacFrameworkRoot as an environment variable when running MSBuild tests, because we have command-line tools that needs it (bgen), and only passing it as a MSBuild parameter doesn't reach the environment (and any subprocesses). --- tests/common/mac/ProjectTestHelpers.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/common/mac/ProjectTestHelpers.cs b/tests/common/mac/ProjectTestHelpers.cs index 147d60a27338..925ee4175703 100644 --- a/tests/common/mac/ProjectTestHelpers.cs +++ b/tests/common/mac/ProjectTestHelpers.cs @@ -236,6 +236,7 @@ public static string BuildProject (string csprojTarget, bool isUnified, bool sho Environment.SetEnvironmentVariable ("TargetFrameworkFallbackSearchPaths", rootDirectory + "/Library/Frameworks/Mono.framework/External/xbuild-frameworks"); Environment.SetEnvironmentVariable ("MSBuildExtensionsPathFallbackPathsOverride", rootDirectory + "/Library/Frameworks/Mono.framework/External/xbuild"); Environment.SetEnvironmentVariable ("XAMMAC_FRAMEWORK_PATH", rootDirectory + "/Library/Frameworks/Xamarin.Mac.framework/Versions/Current"); + Environment.SetEnvironmentVariable ("XamarinMacFrameworkRoot", rootDirectory + "/Library/Frameworks/Xamarin.Mac.framework/Versions/Current"); // This is to force build to use our mmp and not system mmp StringBuilder buildArgs = new StringBuilder (); From acad87b7f663615eb7cf2cb34c7ab866d7f0b90e Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Mon, 30 Jul 2018 16:03:35 +0200 Subject: [PATCH 20/23] Bump system mono to 5.16 to see if that gets an MSBuild with the fixes we need for this PR. --- Make.config | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Make.config b/Make.config index c22e4396b52e..7717cb30ae42 100644 --- a/Make.config +++ b/Make.config @@ -62,9 +62,9 @@ XCODE_URL=http://xamarin-storage/bot-provisioning/xcodes/Xcode_9.4.xip XCODE_DEVELOPER_ROOT=/Applications/Xcode94.app/Contents/Developer # Minimum Mono version -MIN_MONO_VERSION=5.14.0.136 -MAX_MONO_VERSION=5.14.99 -MIN_MONO_URL=https://xamjenkinsartifact.azureedge.net/build-package-osx-mono/2018-04/111/07c8f25fe536dbb7e244f965aa3f9a871f41e953/MonoFramework-MDK-5.14.0.136.macos10.xamarin.universal.pkg +MIN_MONO_VERSION=5.16.0.5 +MAX_MONO_VERSION=5.16.99 +MIN_MONO_URL=https://xamjenkinsartifact.azureedge.net/build-package-osx-mono/2018-06/7/7627a5f9eeba0fd846731ad0c498556f55be1a34/MonoFramework-MDK-5.16.0.5.macos10.xamarin.universal.pkg # Minimum Visual Studio version MIN_VISUAL_STUDIO_URL=https://download.visualstudio.microsoft.com/download/pr/11550896/783d2219a348f93b6988fb415951788a/VisualStudioForMac-Preview-7.4.0.985.dmg From 42645d52b0ef8c174d9caae6a2fcebf85e0ab214 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Tue, 31 Jul 2018 11:48:15 +0200 Subject: [PATCH 21/23] [tests][msbuild] Seems like we need to copy System.Reflection.Metadata.dll locally, since the MSBuild dlls need it. --- .../tests/Xamarin.iOS.Tasks.Tests/Xamarin.iOS.Tasks.Tests.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/msbuild/tests/Xamarin.iOS.Tasks.Tests/Xamarin.iOS.Tasks.Tests.csproj b/msbuild/tests/Xamarin.iOS.Tasks.Tests/Xamarin.iOS.Tasks.Tests.csproj index abb0c6446b2f..abb5725e56a7 100644 --- a/msbuild/tests/Xamarin.iOS.Tasks.Tests/Xamarin.iOS.Tasks.Tests.csproj +++ b/msbuild/tests/Xamarin.iOS.Tasks.Tests/Xamarin.iOS.Tasks.Tests.csproj @@ -32,6 +32,7 @@ + From 4362842b68faa39062246898cf6d9e32dfe8e84a Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Thu, 11 Oct 2018 12:25:47 +0200 Subject: [PATCH 22/23] [mmptests] Update according to MSBuild changes. --- tests/mmptest/src/MMPTest.cs | 6 +++--- tests/mmptest/src/PackageReferenceTests.cs | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/mmptest/src/MMPTest.cs b/tests/mmptest/src/MMPTest.cs index 4024b4a8bad7..118111f0c136 100644 --- a/tests/mmptest/src/MMPTest.cs +++ b/tests/mmptest/src/MMPTest.cs @@ -685,15 +685,15 @@ public void BuildingSameSolutionTwice_ShouldNotRunACToolTwice () string project = TI.GenerateUnifiedExecutableProject (test); - string buildOutput = TI.BuildProject (project, true, diagnosticMSBuild: true, useMSBuild: true); + string buildOutput = TI.BuildProject (project, true); Assert.True (buildOutput.Contains ("actool execution started with arguments"), $"Initial build should run actool"); - buildOutput = TI.BuildProject (project, true, diagnosticMSBuild: true, useMSBuild: true); + buildOutput = TI.BuildProject (project, true); Assert.False (buildOutput.Contains ("actool execution started with arguments"), $"Second build should not run actool"); TI.RunAndAssert ("touch", Path.Combine (tmpDir, "Assets.xcassets/AppIcon.appiconset/AppIcon-256@2x.png"), "touch icon"); - buildOutput = TI.BuildProject (project, true, diagnosticMSBuild: true, useMSBuild: true); + buildOutput = TI.BuildProject (project, true); Assert.True (buildOutput.Contains ("actool execution started with arguments"), $"Build after touching icon must run actool"); }); } diff --git a/tests/mmptest/src/PackageReferenceTests.cs b/tests/mmptest/src/PackageReferenceTests.cs index 25e534496619..8dc13526a6d4 100644 --- a/tests/mmptest/src/PackageReferenceTests.cs +++ b/tests/mmptest/src/PackageReferenceTests.cs @@ -26,7 +26,7 @@ public void AppsWithPackageReferencs_BuildAndRun (bool full) string project = TI.GenerateUnifiedExecutableProject (config); TI.NugetRestore (project); - TI.BuildProject (project, true, useMSBuild: true); + TI.BuildProject (project, true); TI.RunGeneratedUnifiedExecutable (config); }); } @@ -44,7 +44,7 @@ public void ExtensionProjectPackageReferencs_Build () TI.CopyFileWithSubstitutions (main, main, s => s.Replace ("%TESTCODE%", TestCode)); TI.NugetRestore (project); - string output = TI.BuildProject (Path.Combine (tmpDir, "Today/TodayExtensionTest.csproj"), isUnified: true, useMSBuild: true); + string output = TI.BuildProject (Path.Combine (tmpDir, "Today/TodayExtensionTest.csproj"), isUnified: true); Assert.IsTrue (!output.Contains ("MM2013")); }); } From 5fbfacc2a8b92b30ba69b1af3bb0ce05ff90955d Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Mon, 15 Oct 2018 10:41:33 +0200 Subject: [PATCH 23/23] [tests] Only restore packages.config, not the mtouch test project. Restoring the mtouch.csproj makes nuget try to restore Mono.Cecil.csproj as well, which doesn't work. So just restore what's listed in our packages.config instead. --- tests/mtouch/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/mtouch/Makefile b/tests/mtouch/Makefile index 1caa1b4ab093..0043a940c067 100644 --- a/tests/mtouch/Makefile +++ b/tests/mtouch/Makefile @@ -29,7 +29,7 @@ run-tests: test.config @[[ ! -e .failed-stamp ]] build: - $(Q) $(SYSTEM_MONO) /Library/Frameworks//Mono.framework/Versions/Current/lib/mono/nuget/NuGet.exe restore mtouch.sln + $(Q) $(SYSTEM_MONO) /Library/Frameworks//Mono.framework/Versions/Current/lib/mono/nuget/NuGet.exe restore packages.config $(SYSTEM_XBUILD) mtouch.csproj $(XBUILD_VERBOSITY) $(Q) rm -f .failed-stamp