Skip to content

Commit

Permalink
Submodule MonoTouch.Dialog. (#13058)
Browse files Browse the repository at this point in the history
* Submodule MonoTouch.Dialog.

Submodule MonoTouch.Dialog, so that we can easily build it using .NET. This
submodule will become redundant when/if we publish a .NET version of
MonoTouch.Dialog, but until that happens we need it at least for our own test
suites.

This also means we have to copy our NuGet.config and global.json files to the
MonoTouch.Dialog project directory so that we point msbuild to use our local
build.

New commits in spouliot/Touch.Unit:

* xamarin/Touch.Unit@cbda703 [Touch.Client] Use MonoTouch.Dialog from a submodule. (#109)

Diff: https://github.com/spouliot/Touch.Unit/compare/3345db2f4e6408fdf2e8f099251c5c1310b56937..cbda70358360329854ea399100a2b5b04ae43982

* Use relative path for submodule.

And fix indentation and set the branch name.

* Don't use 'RootTestsDirectory' when it might not be defined yet.

* [tests] Our test projects don't need to reference MonoTouch.Dialog directly.

The projects get the MonoTouch.Dialog reference indirectly through the
Touch.Client project reference.

* [tests] Only validate unique errors in the .NET unit tests.

* [tests] No need to reference System.Json anymore, that's handled directly in the MonoTouch.Dialog project.

* [tests] Reference nunit.framework.targets so we get a workaround for an NUnit issue everywhere.

* [msbuild] Only try to create a package if we're able to create an app bundle.

This fixes an issue where a library project would try (and fail) to create a
package when 'CreatePackage=true' (which could be set for the executable
project, but inherited by the library project since the executable project
depends on it).

* [tests] Adjust PackTest.BindingXcFrameworksProject to not set the AssemblyName property.

MSBuild ends up being very confused when the project we're trying to build
depends on other projects, because AssemblyName is set for all the projects
being build, and MSBuild complains about ambiguous projects:

> error: Ambiguous project name 'bindings-xcframework-test'
  • Loading branch information
rolfbjarne authored Oct 26, 2021
1 parent aca9bb0 commit b70e6f4
Show file tree
Hide file tree
Showing 20 changed files with 36 additions and 60 deletions.
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@
path = external/Xamarin.MacDev
url = ../../xamarin/Xamarin.MacDev
branch = main
[submodule "external/MonoTouch.Dialog"]
path = external/MonoTouch.Dialog
url = ../../migueldeicaza/MonoTouch.Dialog
branch = dotnet
1 change: 1 addition & 0 deletions Make.config
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ XAMARIN_MACDEV_PATH=$(TOP)/external/Xamarin.MacDev
MACCORE_PATH=$(TOP)/../maccore
MACIOS_BINARIES_PATH=$(TOP)/external/macios-binaries
IKVM_PATH=$(TOP)/external/ikvm-fork
MONOTOUCH_DIALOG_PATH=$(TOP)/external/MonoTouch.Dialog

MONO_PREFIX ?= /Library/Frameworks/Mono.framework/Versions/Current
SYSTEM_MCS=$(MONO_PREFIX)/bin/mcs
Expand Down
1 change: 1 addition & 0 deletions external/MonoTouch.Dialog
Submodule MonoTouch.Dialog added at 8e60f8
2 changes: 1 addition & 1 deletion external/Touch.Unit
1 change: 1 addition & 0 deletions mk/versions.mk
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ $(eval $(call CheckSubmoduleTemplate,opentk,OPENTK))
$(eval $(call CheckSubmoduleTemplate,Xamarin.MacDev,XAMARIN_MACDEV))
$(eval $(call CheckSubmoduleTemplate,macios-binaries,MACIOS_BINARIES))
$(eval $(call CheckSubmoduleTemplate,ikvm-fork,IKVM))
$(eval $(call CheckSubmoduleTemplate,MonoTouch.Dialog,MONOTOUCH_DIALOG))

include $(TOP)/mk/xamarin.mk

Expand Down
2 changes: 1 addition & 1 deletion msbuild/Xamarin.Shared/Xamarin.Shared.targets
Original file line number Diff line number Diff line change
Expand Up @@ -2250,7 +2250,7 @@ Copyright (C) 2018 Microsoft. All rights reserved.
</CompileProductDefinition>
</Target>

<Target Name="_CreateInstaller" Condition="$(CreatePackage)" DependsOnTargets="Codesign;_CompileProductDefinition;_WriteAppManifest">
<Target Name="_CreateInstaller" Condition="'$(CreatePackage)' == 'true' And '$(_CanOutputAppBundle)' == 'true'" DependsOnTargets="Codesign;_CompileProductDefinition;_WriteAppManifest">
<CreateInstallerPackage
SessionId="$(BuildSessionId)"
Condition="'$(IsMacEnabled)' == 'true'"
Expand Down
13 changes: 8 additions & 5 deletions tests/common/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -769,20 +769,23 @@ public static void FixupTestFiles (string directory, string mode)
}
}

public static string [] CopyDotNetSupportingFiles (string targetDirectory)
public static string [] CopyDotNetSupportingFiles (params string[] targetDirectories)
{
var srcDirectory = Path.Combine (SourceRoot, "tests", "dotnet");
var files = new string [] { "global.json", "NuGet.config" };
var targets = new string [files.Length];
var targets = new List<string> ();
for (var i = 0; i < files.Length; i++) {
var fn = files [i];
targets [i] = Path.Combine (targetDirectory, fn);
var src = Path.Combine (srcDirectory, fn);
if (!File.Exists (src))
ExecutionHelper.Execute ("make", new [] { "-C", srcDirectory, fn });
File.Copy (src, targets [i], true);
foreach (var targetDirectory in targetDirectories) {
var target = Path.Combine (targetDirectory, fn);
File.Copy (src, target, true);
targets.Add (target);
}
}
return targets;
return targets.ToArray ();
}

public static Dictionary<string, string> GetBuildEnvironment (ApplePlatform platform)
Expand Down
8 changes: 6 additions & 2 deletions tests/common/shared-dotnet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
<SupportedOSPlatformVersion>10.0</SupportedOSPlatformVersion>
</PropertyGroup>
<ItemGroup Condition="'$(_PlatformName)' == 'iOS'">
<PackageReference Include="MonoTouch.Dialog" Version="2.0.0-pre1" />
</ItemGroup>

<!-- Logic for tvOS -->
Expand All @@ -22,7 +21,6 @@
<SupportedOSPlatformVersion>10.0</SupportedOSPlatformVersion>
</PropertyGroup>
<ItemGroup Condition="$(TargetFramework.EndsWith('-tvos'))">
<PackageReference Include="MonoTouch.Dialog" Version="2.0.0-pre1" />
</ItemGroup>

<!-- Logic for macOS -->
Expand All @@ -40,4 +38,10 @@
</PropertyGroup>

<!-- Logic for all test suites -->
<ItemGroup>
<PackageReference Include="NUnitLite" Version="3.12.0" />
<ProjectReference Include="$(MSBuildThisFileDirectory)\..\..\external\Touch.Unit\Touch.Client\dotnet\$(_PlatformName)\Touch.Client-$(_PlatformName).dotnet.csproj" />
</ItemGroup>

<Import Project="$(MSBuildThisFileDirectory)/../nunit.framework.targets" />
</Project>
1 change: 1 addition & 0 deletions tests/dotnet/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,4 @@ copy-dotnet-config: $(TARGETS)
$(CP) -c NuGet.config global.json "$$dir"; \
done
$(Q) $(CP) -c NuGet.config global.json $(TOP)/external/Touch.Unit/Touch.Client/dotnet
$(Q) $(CP) -c NuGet.config global.json $(TOP)/external/MonoTouch.Dialog/MonoTouch.Dialog/dotnet
10 changes: 5 additions & 5 deletions tests/dotnet/UnitTests/PackTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ public void BindingFrameworksProject (ApplePlatform platform, bool noBindingEmbe
public void BindingXcFrameworksProject (ApplePlatform platform, bool noBindingEmbedding)
{
var project = "bindings-xcframework-test";
var assemblyName = "bindings-framework-test";
Configuration.IgnoreIfIgnoredPlatform (platform);

var project_path = Path.Combine (Configuration.RootPath, "tests", project, "dotnet", platform.AsString (), $"{project}.csproj");
Expand All @@ -123,23 +124,22 @@ public void BindingXcFrameworksProject (ApplePlatform platform, bool noBindingEm
properties ["OutputPath"] = outputPath + Path.DirectorySeparatorChar;
properties ["IntermediateOutputPath"] = intermediateOutputPath + Path.DirectorySeparatorChar;
properties ["NoBindingEmbedding"] = noBindingEmbedding ? "true" : "false";
properties ["AssemblyName"] = project;

DotNet.AssertPack (project_path, properties);

var nupkg = Path.Combine (outputPath, project + ".1.0.0.nupkg");
var nupkg = Path.Combine (outputPath, assemblyName + ".1.0.0.nupkg");
Assert.That (nupkg, Does.Exist, "nupkg existence");

var archive = ZipFile.OpenRead (nupkg);
var files = archive.Entries.Select (v => v.FullName).ToHashSet ();
Assert.That (archive.Entries.Count, Is.EqualTo (noBindingEmbedding ? 6 : 5), $"nupkg file count - {nupkg}");
Assert.That (files, Does.Contain (project + ".nuspec"), "nuspec");
Assert.That (files, Does.Contain (assemblyName + ".nuspec"), "nuspec");
Assert.That (files, Does.Contain ("_rels/.rels"), ".rels");
Assert.That (files, Does.Contain ("[Content_Types].xml"), "[Content_Types].xml");
Assert.That (files, Does.Contain ($"lib/{platform.ToFrameworkWithDefaultVersion ()}/{project}.dll"), $"{project}.dll");
Assert.That (files, Does.Contain ($"lib/{platform.ToFrameworkWithDefaultVersion ()}/{assemblyName}.dll"), $"{assemblyName}.dll");
Assert.That (files, Has.Some.Matches<string> (v => v.StartsWith ("package/services/metadata/core-properties/", StringComparison.Ordinal) && v.EndsWith (".psmdcp", StringComparison.Ordinal)), "psmdcp");
if (noBindingEmbedding) {
Assert.That (files, Does.Contain ($"lib/{platform.ToFrameworkWithDefaultVersion ()}/{project}.resources.zip"), $"{project}.resources.zip");
Assert.That (files, Does.Contain ($"lib/{platform.ToFrameworkWithDefaultVersion ()}/{assemblyName}.resources.zip"), $"{assemblyName}.resources.zip");
}
}

Expand Down
10 changes: 7 additions & 3 deletions tests/dotnet/UnitTests/ProjectTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,10 @@ public void BuildInterdependentBindingProjects (string platform)
Configuration.CopyDotNetSupportingFiles (dotnet_bindings_dir);
Configuration.CopyDotNetSupportingFiles (dotnet_bindings_dir.Replace (assemblyName, "bindings-test"));
Configuration.CopyDotNetSupportingFiles (dotnet_bindings_dir.Replace (assemblyName, "bindings-test2"));
var cleanupSupportFiles = Configuration.CopyDotNetSupportingFiles (Path.Combine (Configuration.SourceRoot, "external", "Touch.Unit", "Touch.Client/dotnet"));
var cleanupSupportFiles = Configuration.CopyDotNetSupportingFiles (
Path.Combine (Configuration.SourceRoot, "external", "Touch.Unit", "Touch.Client", "dotnet"),
Path.Combine (Configuration.SourceRoot, "external", "MonoTouch.Dialog", "MonoTouch.Dialog", "dotnet")
);
try {
var result = DotNet.AssertBuild (project_path, verbosity);
var lines = BinLog.PrintToLines (result.BinLogPath);
Expand Down Expand Up @@ -476,8 +479,9 @@ public void InvalidRuntimeIdentifier (ApplePlatform platform, string runtimeIden
var properties = GetDefaultProperties (runtimeIdentifier);
var rv = DotNet.AssertBuildFailure (project_path, properties);
var errors = BinLog.GetBuildLogErrors (rv.BinLogPath).ToArray ();
Assert.AreEqual (1, errors.Length, "Error count");
Assert.AreEqual ($"The RuntimeIdentifier '{runtimeIdentifier}' is invalid.", errors [0].Message, "Error message");
var uniqueErrors = errors.Select (v => v.Message).Distinct ().ToArray ();
Assert.AreEqual (1, uniqueErrors.Length, "Error count");
Assert.AreEqual ($"The RuntimeIdentifier '{runtimeIdentifier}' is invalid.", uniqueErrors [0], "Error message");
}

[Test]
Expand Down
5 changes: 0 additions & 5 deletions tests/framework-test/dotnet/shared.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@
<Import Project="$(RootTestsDirectory)/common/shared-dotnet.csproj" />

<ItemGroup>
<PackageReference Include="NUnitLite" Version="3.12.0" />
<ProjectReference Include="$(RootTestsDirectory)\..\external\Touch.Unit\Touch.Client\dotnet\$(_PlatformName)\Touch.Client-$(_PlatformName).dotnet.csproj" />
<!-- MonoTouch.Dialog references System.Json, which isn't shipped with .NET5, so reference the NuGet instead -->
<PackageReference Include="System.Json" Version="4.7.1" />

<ProjectReference Include="$(RootTestsDirectory)\bindings-framework-test\dotnet\$(_PlatformName)\bindings-framework-test.csproj" />
</ItemGroup>

Expand Down
4 changes: 0 additions & 4 deletions tests/fsharp/dotnet/shared.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@
<Import Project="$(RootTestsDirectory)/common/shared-dotnet.csproj" />

<ItemGroup>
<PackageReference Include="NUnitLite" Version="3.12.0" />
<ProjectReference Include="$(RootTestsDirectory)\..\external\Touch.Unit\Touch.Client\dotnet\$(_PlatformName)\Touch.Client-$(_PlatformName).dotnet.csproj" />
<!-- MonoTouch.Dialog references System.Json, which isn't shipped with .NET5, so reference the NuGet instead -->
<PackageReference Include="System.Json" Version="4.7.1" />
<PackageReference Include="FSharp.Core" Version="5.0.0" />
</ItemGroup>

Expand Down
5 changes: 0 additions & 5 deletions tests/interdependent-binding-projects/dotnet/shared.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@
<Import Project="$(RootTestsDirectory)\nunit.framework.targets" />

<ItemGroup>
<PackageReference Include="NUnitLite" Version="3.12.0" />
<ProjectReference Include="$(RootTestsDirectory)\..\external\Touch.Unit\Touch.Client\dotnet\$(_PlatformName)\Touch.Client-$(_PlatformName).dotnet.csproj" />
<!-- MonoTouch.Dialog references System.Json, which isn't shipped with .NET5, so reference the NuGet instead -->
<PackageReference Include="System.Json" Version="4.7.1" />

<ProjectReference Include="$(RootTestsDirectory)\bindings-test\dotnet\$(_PlatformName)\bindings-test.csproj" />
<ProjectReference Include="$(RootTestsDirectory)\bindings-test2\dotnet\$(_PlatformName)\bindings-test2.csproj" />
</ItemGroup>
Expand Down
7 changes: 0 additions & 7 deletions tests/introspection/dotnet/shared.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,6 @@
<Import Project="$(RootTestsDirectory)/common/shared-dotnet.csproj" />
<Import Project="$(RootTestsDirectory)\nunit.framework.targets" />

<ItemGroup>
<PackageReference Include="NUnitLite" Version="3.12.0" />
<ProjectReference Include="$(RootTestsDirectory)\..\external\Touch.Unit\Touch.Client\dotnet\$(_PlatformName)\Touch.Client-$(_PlatformName).dotnet.csproj" />
<!-- MonoTouch.Dialog references System.Json, which isn't shipped with .NET5, so reference the NuGet instead -->
<PackageReference Include="System.Json" Version="4.7.1" />
</ItemGroup>

<ItemGroup Condition="$(TargetFramework.EndsWith('-macos'))">
<Compile Include="$(IntrospectionTestDirectory)\Mac\MacApiCtorInitTest.cs" />
<Compile Include="$(IntrospectionTestDirectory)\Mac\MacApiFieldTest.cs" />
Expand Down
4 changes: 0 additions & 4 deletions tests/linker/ios/dont link/dotnet/shared.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
<Import Project="$(RootTestsDirectory)\nunit.framework.targets" />

<ItemGroup>
<PackageReference Include="NUnitLite" Version="3.12.0" />
<ProjectReference Include="$(RootTestsDirectory)\..\external\Touch.Unit\Touch.Client\dotnet\$(_PlatformName)\Touch.Client-$(_PlatformName).dotnet.csproj" />
<!-- MonoTouch.Dialog references System.Json, which isn't shipped with .NET5, so reference the NuGet instead -->
<PackageReference Include="System.Json" Version="4.7.1" />
<ProjectReference Include="$(RootTestsDirectory)\BundledResources\dotnet\$(_PlatformName)\BundledResources.csproj" />
</ItemGroup>

Expand Down
4 changes: 0 additions & 4 deletions tests/linker/ios/link all/dotnet/shared.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@

<ItemGroup>
<PackageReference Include="System.ComponentModel.Composition" Version="4.7.0" />
<PackageReference Include="NUnitLite" Version="3.12.0" />
<ProjectReference Include="$(RootTestsDirectory)\..\external\Touch.Unit\Touch.Client\dotnet\$(_PlatformName)\Touch.Client-$(_PlatformName).dotnet.csproj" />
<!-- MonoTouch.Dialog references System.Json, which isn't shipped with .NET5, so reference the NuGet instead -->
<PackageReference Include="System.Json" Version="4.7.1" />
<ProjectReference Include="$(RootTestsDirectory)\BundledResources\dotnet\$(_PlatformName)\BundledResources.csproj" />
<ProjectReference Include="$(RootTestsDirectory)\bindings-test\dotnet\$(_PlatformName)\bindings-test.csproj" />
</ItemGroup>
Expand Down
4 changes: 0 additions & 4 deletions tests/linker/ios/link sdk/dotnet/shared.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@
<HintPath>$(ThisTestDirectory)/support.dll</HintPath>
</Reference>

<PackageReference Include="NUnitLite" Version="3.12.0" />
<ProjectReference Include="$(RootTestsDirectory)\..\external\Touch.Unit\Touch.Client\dotnet\$(_PlatformName)\Touch.Client-$(_PlatformName).dotnet.csproj" />
<!-- MonoTouch.Dialog references System.Json, which isn't shipped with .NET5, so reference the NuGet instead -->
<PackageReference Include="System.Json" Version="4.7.1" />
<ProjectReference Include="$(RootTestsDirectory)\BundledResources\dotnet\$(_PlatformName)\BundledResources.csproj" />
<ProjectReference Include="$(RootTestsDirectory)\bindings-test\dotnet\$(_PlatformName)\bindings-test.csproj" />
</ItemGroup>
Expand Down
5 changes: 0 additions & 5 deletions tests/monotouch-test/dotnet/shared.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@
<Import Project="$(RootTestsDirectory)/common/shared-dotnet.csproj" />

<ItemGroup>
<PackageReference Include="NUnitLite" Version="3.12.0" />
<ProjectReference Include="$(RootTestsDirectory)\..\external\Touch.Unit\Touch.Client\dotnet\$(_PlatformName)\Touch.Client-$(_PlatformName).dotnet.csproj" />
<!-- MonoTouch.Dialog references System.Json, which isn't shipped with .NET5, so reference the NuGet instead -->
<PackageReference Include="System.Json" Version="4.7.1" />

<ProjectReference Include="$(RootTestsDirectory)\EmbeddedResources\dotnet\$(_PlatformName)\EmbeddedResources.csproj" />
<ProjectReference Include="$(RootTestsDirectory)\bindings-test\dotnet\$(_PlatformName)\bindings-test.csproj" />
<ProjectReference Include="$(RootTestsDirectory)\fsharplibrary\dotnet\$(_PlatformName)\fsharplibrary.fsproj" />
Expand Down
5 changes: 0 additions & 5 deletions tests/xcframework-test/dotnet/shared.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@
<Import Project="$(RootTestsDirectory)/common/shared-dotnet.csproj" />

<ItemGroup>
<PackageReference Include="NUnitLite" Version="3.12.0" />
<ProjectReference Include="$(RootTestsDirectory)\..\external\Touch.Unit\Touch.Client\dotnet\$(_PlatformName)\Touch.Client-$(_PlatformName).dotnet.csproj" />
<!-- MonoTouch.Dialog references System.Json, which isn't shipped with .NET5, so reference the NuGet instead -->
<PackageReference Include="System.Json" Version="4.7.1" />

<ProjectReference Include="$(RootTestsDirectory)\bindings-xcframework-test\dotnet\$(_PlatformName)\bindings-xcframework-test.csproj" />
</ItemGroup>

Expand Down

5 comments on commit b70e6f4

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ [CI Build] Tests failed on Build ❌

Tests failed on Build.

API diff

✅ API Diff from stable

View API diff
View dotnet API diff
View dotnet legacy API diff
View dotnet iOS-MacCatalayst API diff

Packages generated

View packages

Test results

1 tests failed, 217 tests passed.

Failed tests

  • link all/Mac Catalyst [dotnet]/Debug [dotnet]: TimedOut (Execution timed out after 1200 seconds.
    No test log file was produced)

Pipeline on Agent XAMBOT-1030.BigSur'
Submodule MonoTouch.Dialog. (#13058)

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Tests were not ran (VSTS: device tests tvOS). ⚠️

Results were skipped for this run due to provisioning problems Azure Devops. Please contact the bot administrator.

Pipeline on Agent
Submodule MonoTouch.Dialog. (#13058)

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Tests were not ran (VSTS: device tests iOS). ⚠️

Results were skipped for this run due to provisioning problems Azure Devops. Please contact the bot administrator.

Pipeline on Agent
Submodule MonoTouch.Dialog. (#13058)

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Tests passed on macOS M1 - Mac Big Sur (11.5) ✅

Tests passed

All tests on macOS X M1 - Mac Big Sur (11.5) passed.

Pipeline on Agent
Submodule MonoTouch.Dialog. (#13058)

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ Tests failed on macOS Mac Mojave (10.14) ❌

Tests failed on Mac Mojave (10.14).

Failed tests are:

  • xammac_tests
  • monotouch-test

Pipeline on Agent
Submodule MonoTouch.Dialog. (#13058)

Please sign in to comment.