From 180a7e0bb9319ff48288e6e5c3930a4a064f7b2e Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Wed, 10 Jul 2024 12:57:30 +0200 Subject: [PATCH 1/4] [tests] Fix a couple of minor issues. (#20843) * xtro: Fix how we build the u2todo project to actually build the correct project. * Don't import eng/Versions.props in several test projects, it's already imported in a Directory.Build.props further up the directory hierarchy. --- tests/dotnet/Windows/InstallDotNet.csproj | 2 -- .../FrameworksInRuntimesNativeDirectory.csproj | 1 - ...XCFrameworkWithStaticLibraryInRuntimesNativeDirectory.csproj | 1 - tests/xharness/Xharness.Tests/Xharness.Tests.csproj | 1 - tests/xharness/xharness.csproj | 1 - tests/xtro-sharpie/Makefile | 2 +- tests/xtro-sharpie/xtro-sharpie/xtro-sharpie.csproj | 1 - 7 files changed, 1 insertion(+), 8 deletions(-) diff --git a/tests/dotnet/Windows/InstallDotNet.csproj b/tests/dotnet/Windows/InstallDotNet.csproj index 78bc126d48..2f208f0f27 100644 --- a/tests/dotnet/Windows/InstallDotNet.csproj +++ b/tests/dotnet/Windows/InstallDotNet.csproj @@ -54,8 +54,6 @@ - - netstandard2.0 false diff --git a/tests/test-libraries/nugets/FrameworksInRuntimesNativeDirectory/FrameworksInRuntimesNativeDirectory.csproj b/tests/test-libraries/nugets/FrameworksInRuntimesNativeDirectory/FrameworksInRuntimesNativeDirectory.csproj index e6a6de9c6e..48a7b1b683 100644 --- a/tests/test-libraries/nugets/FrameworksInRuntimesNativeDirectory/FrameworksInRuntimesNativeDirectory.csproj +++ b/tests/test-libraries/nugets/FrameworksInRuntimesNativeDirectory/FrameworksInRuntimesNativeDirectory.csproj @@ -12,7 +12,6 @@ $(RootTestDirectory)/test-libraries/frameworks - diff --git a/tests/test-libraries/nugets/XCFrameworkWithStaticLibraryInRuntimesNativeDirectory/XCFrameworkWithStaticLibraryInRuntimesNativeDirectory.csproj b/tests/test-libraries/nugets/XCFrameworkWithStaticLibraryInRuntimesNativeDirectory/XCFrameworkWithStaticLibraryInRuntimesNativeDirectory.csproj index e170001bdd..8171afed83 100644 --- a/tests/test-libraries/nugets/XCFrameworkWithStaticLibraryInRuntimesNativeDirectory/XCFrameworkWithStaticLibraryInRuntimesNativeDirectory.csproj +++ b/tests/test-libraries/nugets/XCFrameworkWithStaticLibraryInRuntimesNativeDirectory/XCFrameworkWithStaticLibraryInRuntimesNativeDirectory.csproj @@ -12,7 +12,6 @@ $(RootTestDirectory)/test-libraries - diff --git a/tests/xharness/Xharness.Tests/Xharness.Tests.csproj b/tests/xharness/Xharness.Tests/Xharness.Tests.csproj index 6477284ac1..cba5528d90 100644 --- a/tests/xharness/Xharness.Tests/Xharness.Tests.csproj +++ b/tests/xharness/Xharness.Tests/Xharness.Tests.csproj @@ -52,7 +52,6 @@ - {e1f53f80-8399-499b-8017-c414b9cd263b} diff --git a/tests/xharness/xharness.csproj b/tests/xharness/xharness.csproj index 404b9173cc..6d30a585e1 100644 --- a/tests/xharness/xharness.csproj +++ b/tests/xharness/xharness.csproj @@ -35,7 +35,6 @@ Project --configure --autoconf --rootdir ../../../.. - diff --git a/tests/xtro-sharpie/Makefile b/tests/xtro-sharpie/Makefile index 3497baa72d..4d44916a4f 100644 --- a/tests/xtro-sharpie/Makefile +++ b/tests/xtro-sharpie/Makefile @@ -308,7 +308,7 @@ remove-empty-files: U2TODO = u2todo/bin/Debug/u2todo.dll $(U2TODO): $(wildcard u2todo/*.cs u2todo/*.csproj xtro-sharpie/Filter.cs) - $(Q) unset MSBUILD_EXE_PATH && $(DOTNET) build $(DOTNET_BUILD_VERBOSITY) /bl:$@.binlog + $(Q) unset MSBUILD_EXE_PATH && $(DOTNET) build u2todo/u2todo.csproj $(DOTNET_BUILD_VERBOSITY) /bl:$@.binlog $(Q) touch $@ unclassified2todo-classic: $(U2TODO) diff --git a/tests/xtro-sharpie/xtro-sharpie/xtro-sharpie.csproj b/tests/xtro-sharpie/xtro-sharpie/xtro-sharpie.csproj index 8f78421a30..d6105ef85f 100644 --- a/tests/xtro-sharpie/xtro-sharpie/xtro-sharpie.csproj +++ b/tests/xtro-sharpie/xtro-sharpie/xtro-sharpie.csproj @@ -1,6 +1,5 @@ - Debug AnyCPU From f2ae944988cd0d0c56f3cde1a51b459055b87e35 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Wed, 10 Jul 2024 12:58:16 +0200 Subject: [PATCH 2/4] [system-dependencies] Only download the simulators for platforms we target. (#20842) In particular we don't need the visionOS simulator/platform. --- system-dependencies.sh | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/system-dependencies.sh b/system-dependencies.sh index dcb39b423b..849747b2fe 100755 --- a/system-dependencies.sh +++ b/system-dependencies.sh @@ -314,6 +314,16 @@ function install_mono () { rm -f $MONO_PKG } +function xcodebuild_download_selected_platforms () +{ + log "Executing '$XCODE_DEVELOPER_ROOT/usr/bin/xcodebuild -downloadPlatform iOS' $1" + "$XCODE_DEVELOPER_ROOT/usr/bin/xcodebuild" -downloadPlatform iOS + log "Executing '$XCODE_DEVELOPER_ROOT/usr/bin/xcodebuild -downloadPlatform tvOS' $1" + "$XCODE_DEVELOPER_ROOT/usr/bin/xcodebuild" -downloadPlatform tvOS + log "Executing '$XCODE_DEVELOPER_ROOT/usr/bin/xcodebuild -downloadPlatform watchOS' $1" + "$XCODE_DEVELOPER_ROOT/usr/bin/xcodebuild" -downloadPlatform watchOS +} + function download_xcode_platforms () { if test -n "$IGNORE_SIMULATORS"; then return; fi @@ -336,21 +346,25 @@ function download_xcode_platforms () log "Xcode has additional platforms that must be downloaded ($MUST_INSTALL_RUNTIMES), so installing those." - log "Executing '$XCODE_DEVELOPER_ROOT/usr/bin/xcodebuild -downloadAllPlatforms'" - if ! $SUDO "$XCODE_DEVELOPER_ROOT/usr/bin/xcodebuild" -downloadAllPlatforms; then + log "Executing '$SUDO pkill -9 -f CoreSimulator.framework'" + $SUDO pkill -9 -f "CoreSimulator.framework" || true + if ! xcodebuild_download_selected_platforms; then + log "Executing '$XCODE_DEVELOPER_ROOT/usr/bin/simctl runtime list -v" "$XCODE_DEVELOPER_ROOT/usr/bin/simctl" runtime list -v # Don't exit here, just hope for the best instead. set +x echo "##vso[task.logissue type=warning;sourcepath=system-dependencies.sh]Failed to download all simulator platforms, this may result in problems executing tests in the simulator." set -x else + log "Executing '$XCODE_DEVELOPER_ROOT/usr/bin/simctl runtime list -v" "$XCODE_DEVELOPER_ROOT/usr/bin/simctl" runtime list -v + log "Executing '$XCODE_DEVELOPER_ROOT/usr/bin/simctl list -v" "$XCODE_DEVELOPER_ROOT/usr/bin/simctl" list -v fi - - $SUDO "$XCODE_DEVELOPER_ROOT/usr/bin/xcodebuild" -downloadAllPlatforms - $SUDO "$XCODE_DEVELOPER_ROOT/usr/bin/xcodebuild" -downloadAllPlatforms - $SUDO "$XCODE_DEVELOPER_ROOT/usr/bin/xcodebuild" -downloadAllPlatforms + + xcodebuild_download_selected_platforms "(second time)" || true + xcodebuild_download_selected_platforms "(third time)" || true + xcodebuild_download_selected_platforms "(fourth time)" || true log "Executing '$SUDO $XCODE_DEVELOPER_ROOT/usr/bin/xcodebuild -runFirstLaunch'" $SUDO "$XCODE_DEVELOPER_ROOT/usr/bin/xcodebuild" -runFirstLaunch @@ -368,7 +382,7 @@ function download_xcode_platforms () pkill -9 "Xcode" || log "Xcode was not running." log "Executed 'open xcpref://Xcode.PreferencePane.Platforms'" - log "Executed '$XCODE_DEVELOPER_ROOT/usr/bin/xcodebuild -downloadAllPlatforms'" + log "Finished installing Xcode platforms" } function run_xcode_first_launch () From 7ddf1284a55ca470e6adaaa4cdabcd7920d44f0c Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Wed, 10 Jul 2024 13:00:05 +0200 Subject: [PATCH 3/4] [dotnet] Force 'AppendRuntimeIdentifierToOutputPath=true' for the inner build of universal apps. (#20839) When building universal apps, each inner build must add the runtime identifier to the output path, otherwise the inner builds may conflict with eachother, overwriting eachother's files. That's bad. So we explicitly set `AppendRuntimeIdentifierToOutputPath` to `true` when building inner builds. --- dotnet/targets/Xamarin.Shared.Sdk.targets | 2 ++ .../dotnet/MySimpleApp/Directory.Build.props | 7 ++++ tests/dotnet/UnitTests/ProjectTest.cs | 32 +++++++++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 tests/dotnet/MySimpleApp/Directory.Build.props diff --git a/dotnet/targets/Xamarin.Shared.Sdk.targets b/dotnet/targets/Xamarin.Shared.Sdk.targets index be60333c6f..89536f162f 100644 --- a/dotnet/targets/Xamarin.Shared.Sdk.targets +++ b/dotnet/targets/Xamarin.Shared.Sdk.targets @@ -386,10 +386,12 @@ + + + + false + + + diff --git a/tests/dotnet/UnitTests/ProjectTest.cs b/tests/dotnet/UnitTests/ProjectTest.cs index c2f4318cd7..cd4001996a 100644 --- a/tests/dotnet/UnitTests/ProjectTest.cs +++ b/tests/dotnet/UnitTests/ProjectTest.cs @@ -1984,5 +1984,37 @@ namespace Xamarin.Tests { ExecuteWithMagicWordAndAssert (appExecutable); } } + + [Test] + [TestCase (ApplePlatform.MacOSX, "osx-arm64;osx-x64")] + [TestCase (ApplePlatform.MacCatalyst, "maccatalyst-arm64;maccatalyst-x64")] + public void AppendRuntimeIdentifierToOutputPath_DisableCommandLine (ApplePlatform platform, string runtimeIdentifiers) + { + var project = "MySimpleApp"; + Configuration.IgnoreIfIgnoredPlatform (platform); + Configuration.AssertRuntimeIdentifiersAvailable (platform, runtimeIdentifiers); + + var project_path = GetProjectPath (project, runtimeIdentifiers: runtimeIdentifiers, platform: platform, out var appPath); + Clean (project_path); + var properties = GetDefaultProperties (runtimeIdentifiers); + properties ["cmdline:AppendRuntimeIdentifierToOutputPath"] = "false"; + DotNet.AssertBuild (project_path, properties); + } + + [Test] + [TestCase (ApplePlatform.MacOSX, "osx-arm64;osx-x64")] + [TestCase (ApplePlatform.MacCatalyst, "maccatalyst-arm64;maccatalyst-x64")] + public void AppendRuntimeIdentifierToOutputPath_DisableDirectoryBuildProps (ApplePlatform platform, string runtimeIdentifiers) + { + var project = "MySimpleApp"; + Configuration.IgnoreIfIgnoredPlatform (platform); + Configuration.AssertRuntimeIdentifiersAvailable (platform, runtimeIdentifiers); + + var project_path = GetProjectPath (project, runtimeIdentifiers: runtimeIdentifiers, platform: platform, out var appPath); + Clean (project_path); + var properties = GetDefaultProperties (runtimeIdentifiers); + properties ["SetAppendRuntimeIdentifierToOutputPathToFalse"] = "true"; + DotNet.AssertBuild (project_path, properties); + } } } From ed77cd622460ba70dce74058cccda5462e8658f6 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Wed, 10 Jul 2024 16:30:34 +0200 Subject: [PATCH 4/4] [dotnet] Limit custom dotnet/runtime selection to the current .NET version. (#20840) This way any tests using the previous .NET version still works. --- tests/Directory.Build.targets | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/tests/Directory.Build.targets b/tests/Directory.Build.targets index 9e1b1fc039..d58934cd17 100644 --- a/tests/Directory.Build.targets +++ b/tests/Directory.Build.targets @@ -9,19 +9,16 @@ - - - $(MicrosoftNETCoreAppRefPackageVersion) - - - - - $(MicrosoftNETCoreAppRefPackageVersion) + + $(MicrosoftNETCoreAppRefPackageVersion) + + + $(MicrosoftNETCoreAppRefPackageVersion)