diff --git a/msbuild/Xamarin.MacDev.Tasks/Tasks/FilterStaticFrameworks.cs b/msbuild/Xamarin.MacDev.Tasks/Tasks/FilterStaticFrameworks.cs index 33b62637243f..9bc102faf158 100644 --- a/msbuild/Xamarin.MacDev.Tasks/Tasks/FilterStaticFrameworks.cs +++ b/msbuild/Xamarin.MacDev.Tasks/Tasks/FilterStaticFrameworks.cs @@ -120,9 +120,16 @@ public IEnumerable GetAdditionalItemsToBeCopied () if (FrameworkToPublish is not null) { foreach (var item in FrameworkToPublish) { var fw = item.ItemSpec; + var finfo = new FileInfo (fw); // Copy all the files from the framework to the mac (copying only the executable won't work if it's just a symlink to elsewhere) - if (File.Exists (fw)) + if (finfo.Exists) { + if (finfo.Length == 0) { + // an empty file is most likely an output file from the Mac, so don't overwrite the corresponding file on the Mac with the empty output file from Windows + Log.LogMessage (MessageImportance.Low, "Not copying {0} to the Mac, it's an empty file.", fw); + continue; + } fw = Path.GetDirectoryName (fw); + } if (!Directory.Exists (fw)) continue; foreach (var file in Directory.EnumerateFiles (fw, "*.*", SearchOption.AllDirectories)) { diff --git a/msbuild/Xamarin.MacDev.Tasks/Tasks/GetFullPaths.cs b/msbuild/Xamarin.MacDev.Tasks/Tasks/GetFullPaths.cs index 9c1249946635..dbac5618c101 100644 --- a/msbuild/Xamarin.MacDev.Tasks/Tasks/GetFullPaths.cs +++ b/msbuild/Xamarin.MacDev.Tasks/Tasks/GetFullPaths.cs @@ -65,7 +65,16 @@ bool ExecuteLocally () return !Log.HasLoggedErrors; } - public bool ShouldCopyToBuildServer (ITaskItem item) => true; + public bool ShouldCopyToBuildServer (ITaskItem item) + { + var finfo = new FileInfo (item.ItemSpec); + if (finfo.Exists && finfo.Length == 0) { + // an empty file is most likely an output file from the Mac, so don't overwrite the corresponding file on the Mac with the empty output file from Windows + Log.LogMessage (MessageImportance.Low, "Not copying {0} to the Mac, it's an empty file.", item.ItemSpec); + return false; + } + return true; + } public bool ShouldCreateOutputFile (ITaskItem item) => false; diff --git a/tests/bindings-framework-test/dotnet/shared.csproj b/tests/bindings-framework-test/dotnet/shared.csproj index e574fe3e5015..2b51d55ad1a8 100644 --- a/tests/bindings-framework-test/dotnet/shared.csproj +++ b/tests/bindings-framework-test/dotnet/shared.csproj @@ -9,7 +9,7 @@ True ..\..\..\..\product.snk bindings-framework-test - true + true $([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)\..\..')) $(RootTestsDirectory)\test-libraries diff --git a/tests/dotnet/BindingWithEmbeddedFramework/ApiDefinition.cs b/tests/dotnet/BindingWithEmbeddedFramework/ApiDefinition.cs new file mode 100644 index 000000000000..9ed44545f5ff --- /dev/null +++ b/tests/dotnet/BindingWithEmbeddedFramework/ApiDefinition.cs @@ -0,0 +1 @@ +using Foundation; diff --git a/tests/dotnet/BindingWithEmbeddedFramework/MacCatalyst/BindingWithEmbeddedFramework.csproj b/tests/dotnet/BindingWithEmbeddedFramework/MacCatalyst/BindingWithEmbeddedFramework.csproj new file mode 100644 index 000000000000..02fabd2f8260 --- /dev/null +++ b/tests/dotnet/BindingWithEmbeddedFramework/MacCatalyst/BindingWithEmbeddedFramework.csproj @@ -0,0 +1,8 @@ + + + + net$(BundledNETCoreAppTargetFrameworkVersion)-maccatalyst + + + + diff --git a/tests/dotnet/BindingWithEmbeddedFramework/MacCatalyst/Makefile b/tests/dotnet/BindingWithEmbeddedFramework/MacCatalyst/Makefile new file mode 100644 index 000000000000..110d078f4577 --- /dev/null +++ b/tests/dotnet/BindingWithEmbeddedFramework/MacCatalyst/Makefile @@ -0,0 +1 @@ +include ../shared.mk diff --git a/tests/dotnet/BindingWithEmbeddedFramework/MyClass.cs b/tests/dotnet/BindingWithEmbeddedFramework/MyClass.cs new file mode 100644 index 000000000000..fe10f8297929 --- /dev/null +++ b/tests/dotnet/BindingWithEmbeddedFramework/MyClass.cs @@ -0,0 +1,8 @@ +using System; +namespace BindingWithEmbeddedFramework { + public class MyClass { + public MyClass () + { + } + } +} diff --git a/tests/dotnet/BindingWithEmbeddedFramework/StructsAndEnums.cs b/tests/dotnet/BindingWithEmbeddedFramework/StructsAndEnums.cs new file mode 100644 index 000000000000..a9e01b65501a --- /dev/null +++ b/tests/dotnet/BindingWithEmbeddedFramework/StructsAndEnums.cs @@ -0,0 +1,8 @@ +using System.Runtime.InteropServices; + +namespace BindingWithEmbeddedFramework { + public static class CFunctions { + [DllImport ("XTest.framework/XTest")] + public static extern int theUltimateAnswer (); + } +} diff --git a/tests/dotnet/BindingWithEmbeddedFramework/iOS/BindingWithEmbeddedFramework.csproj b/tests/dotnet/BindingWithEmbeddedFramework/iOS/BindingWithEmbeddedFramework.csproj new file mode 100644 index 000000000000..bb9259517c64 --- /dev/null +++ b/tests/dotnet/BindingWithEmbeddedFramework/iOS/BindingWithEmbeddedFramework.csproj @@ -0,0 +1,8 @@ + + + + net$(BundledNETCoreAppTargetFrameworkVersion)-ios + + + + diff --git a/tests/dotnet/BindingWithEmbeddedFramework/iOS/Makefile b/tests/dotnet/BindingWithEmbeddedFramework/iOS/Makefile new file mode 100644 index 000000000000..110d078f4577 --- /dev/null +++ b/tests/dotnet/BindingWithEmbeddedFramework/iOS/Makefile @@ -0,0 +1 @@ +include ../shared.mk diff --git a/tests/dotnet/BindingWithEmbeddedFramework/macOS/BindingWithEmbeddedFramework.csproj b/tests/dotnet/BindingWithEmbeddedFramework/macOS/BindingWithEmbeddedFramework.csproj new file mode 100644 index 000000000000..71b28ba48c7c --- /dev/null +++ b/tests/dotnet/BindingWithEmbeddedFramework/macOS/BindingWithEmbeddedFramework.csproj @@ -0,0 +1,8 @@ + + + + net$(BundledNETCoreAppTargetFrameworkVersion)-macos + + + + diff --git a/tests/dotnet/BindingWithEmbeddedFramework/macOS/Makefile b/tests/dotnet/BindingWithEmbeddedFramework/macOS/Makefile new file mode 100644 index 000000000000..110d078f4577 --- /dev/null +++ b/tests/dotnet/BindingWithEmbeddedFramework/macOS/Makefile @@ -0,0 +1 @@ +include ../shared.mk diff --git a/tests/dotnet/BindingWithEmbeddedFramework/shared.csproj b/tests/dotnet/BindingWithEmbeddedFramework/shared.csproj new file mode 100644 index 000000000000..703fcb165f27 --- /dev/null +++ b/tests/dotnet/BindingWithEmbeddedFramework/shared.csproj @@ -0,0 +1,15 @@ + + + + true + false + + + + + + + + + + diff --git a/tests/dotnet/BindingWithEmbeddedFramework/shared.mk b/tests/dotnet/BindingWithEmbeddedFramework/shared.mk new file mode 100644 index 000000000000..f555cad4e805 --- /dev/null +++ b/tests/dotnet/BindingWithEmbeddedFramework/shared.mk @@ -0,0 +1,2 @@ +TOP=../../../.. +include $(TOP)/tests/common/shared-dotnet.mk diff --git a/tests/dotnet/BindingWithEmbeddedFramework/tvOS/BindingWithEmbeddedFramework.csproj b/tests/dotnet/BindingWithEmbeddedFramework/tvOS/BindingWithEmbeddedFramework.csproj new file mode 100644 index 000000000000..388e767c58ed --- /dev/null +++ b/tests/dotnet/BindingWithEmbeddedFramework/tvOS/BindingWithEmbeddedFramework.csproj @@ -0,0 +1,8 @@ + + + + net$(BundledNETCoreAppTargetFrameworkVersion)-tvos + + + + diff --git a/tests/dotnet/BindingWithEmbeddedFramework/tvOS/Makefile b/tests/dotnet/BindingWithEmbeddedFramework/tvOS/Makefile new file mode 100644 index 000000000000..110d078f4577 --- /dev/null +++ b/tests/dotnet/BindingWithEmbeddedFramework/tvOS/Makefile @@ -0,0 +1 @@ +include ../shared.mk diff --git a/tests/dotnet/EmbeddedFrameworkInBindingProjectApp/AppDelegate.cs b/tests/dotnet/EmbeddedFrameworkInBindingProjectApp/AppDelegate.cs new file mode 100644 index 000000000000..409eb2388efb --- /dev/null +++ b/tests/dotnet/EmbeddedFrameworkInBindingProjectApp/AppDelegate.cs @@ -0,0 +1,19 @@ +using System; +using System.Runtime.InteropServices; + +using Foundation; + +namespace EmbeddedFrameworkInBindingProjectApp { + public class Program { + static int Main (string [] args) + { + Console.WriteLine ($"Embedded framework: {BindingWithEmbeddedFramework.CFunctions.theUltimateAnswer ()}"); + + GC.KeepAlive (typeof (NSObject)); // prevent linking away the platform assembly + + Console.WriteLine (Environment.GetEnvironmentVariable ("MAGIC_WORD")); + + return 0; + } + } +} diff --git a/tests/dotnet/EmbeddedFrameworkInBindingProjectApp/MacCatalyst/EmbeddedFrameworkInBindingProjectApp.csproj b/tests/dotnet/EmbeddedFrameworkInBindingProjectApp/MacCatalyst/EmbeddedFrameworkInBindingProjectApp.csproj new file mode 100644 index 000000000000..6b0e2c773180 --- /dev/null +++ b/tests/dotnet/EmbeddedFrameworkInBindingProjectApp/MacCatalyst/EmbeddedFrameworkInBindingProjectApp.csproj @@ -0,0 +1,7 @@ + + + + net$(BundledNETCoreAppTargetFrameworkVersion)-maccatalyst + + + diff --git a/tests/dotnet/EmbeddedFrameworkInBindingProjectApp/MacCatalyst/Makefile b/tests/dotnet/EmbeddedFrameworkInBindingProjectApp/MacCatalyst/Makefile new file mode 100644 index 000000000000..110d078f4577 --- /dev/null +++ b/tests/dotnet/EmbeddedFrameworkInBindingProjectApp/MacCatalyst/Makefile @@ -0,0 +1 @@ +include ../shared.mk diff --git a/tests/dotnet/EmbeddedFrameworkInBindingProjectApp/iOS/EmbeddedFrameworkInBindingProjectApp.csproj b/tests/dotnet/EmbeddedFrameworkInBindingProjectApp/iOS/EmbeddedFrameworkInBindingProjectApp.csproj new file mode 100644 index 000000000000..86d408734aa8 --- /dev/null +++ b/tests/dotnet/EmbeddedFrameworkInBindingProjectApp/iOS/EmbeddedFrameworkInBindingProjectApp.csproj @@ -0,0 +1,7 @@ + + + + net$(BundledNETCoreAppTargetFrameworkVersion)-ios + + + diff --git a/tests/dotnet/EmbeddedFrameworkInBindingProjectApp/iOS/Makefile b/tests/dotnet/EmbeddedFrameworkInBindingProjectApp/iOS/Makefile new file mode 100644 index 000000000000..110d078f4577 --- /dev/null +++ b/tests/dotnet/EmbeddedFrameworkInBindingProjectApp/iOS/Makefile @@ -0,0 +1 @@ +include ../shared.mk diff --git a/tests/dotnet/EmbeddedFrameworkInBindingProjectApp/macOS/EmbeddedFrameworkInBindingProjectApp.csproj b/tests/dotnet/EmbeddedFrameworkInBindingProjectApp/macOS/EmbeddedFrameworkInBindingProjectApp.csproj new file mode 100644 index 000000000000..a77287b9ba00 --- /dev/null +++ b/tests/dotnet/EmbeddedFrameworkInBindingProjectApp/macOS/EmbeddedFrameworkInBindingProjectApp.csproj @@ -0,0 +1,7 @@ + + + + net$(BundledNETCoreAppTargetFrameworkVersion)-macos + + + diff --git a/tests/dotnet/EmbeddedFrameworkInBindingProjectApp/macOS/Makefile b/tests/dotnet/EmbeddedFrameworkInBindingProjectApp/macOS/Makefile new file mode 100644 index 000000000000..110d078f4577 --- /dev/null +++ b/tests/dotnet/EmbeddedFrameworkInBindingProjectApp/macOS/Makefile @@ -0,0 +1 @@ +include ../shared.mk diff --git a/tests/dotnet/EmbeddedFrameworkInBindingProjectApp/shared.csproj b/tests/dotnet/EmbeddedFrameworkInBindingProjectApp/shared.csproj new file mode 100644 index 000000000000..1e865a2a17a4 --- /dev/null +++ b/tests/dotnet/EmbeddedFrameworkInBindingProjectApp/shared.csproj @@ -0,0 +1,20 @@ + + + + Exe + + EmbeddedFrameworkInBindingProjectApp + com.xamarin.embeddedframeworkinbindingprojectapp + 1.0 + + + + + + + + + + + + diff --git a/tests/dotnet/EmbeddedFrameworkInBindingProjectApp/shared.mk b/tests/dotnet/EmbeddedFrameworkInBindingProjectApp/shared.mk new file mode 100644 index 000000000000..e22cd18e4914 --- /dev/null +++ b/tests/dotnet/EmbeddedFrameworkInBindingProjectApp/shared.mk @@ -0,0 +1,3 @@ +TOP=../../../.. +TESTNAME=EmbeddedFrameworkInBindingProjectApp +include $(TOP)/tests/common/shared-dotnet.mk diff --git a/tests/dotnet/EmbeddedFrameworkInBindingProjectApp/tvOS/EmbeddedFrameworkInBindingProjectApp.csproj b/tests/dotnet/EmbeddedFrameworkInBindingProjectApp/tvOS/EmbeddedFrameworkInBindingProjectApp.csproj new file mode 100644 index 000000000000..bd487ddcd88d --- /dev/null +++ b/tests/dotnet/EmbeddedFrameworkInBindingProjectApp/tvOS/EmbeddedFrameworkInBindingProjectApp.csproj @@ -0,0 +1,7 @@ + + + + net$(BundledNETCoreAppTargetFrameworkVersion)-tvos + + + diff --git a/tests/dotnet/EmbeddedFrameworkInBindingProjectApp/tvOS/Makefile b/tests/dotnet/EmbeddedFrameworkInBindingProjectApp/tvOS/Makefile new file mode 100644 index 000000000000..110d078f4577 --- /dev/null +++ b/tests/dotnet/EmbeddedFrameworkInBindingProjectApp/tvOS/Makefile @@ -0,0 +1 @@ +include ../shared.mk diff --git a/tests/dotnet/UnitTests/WindowsTest.cs b/tests/dotnet/UnitTests/WindowsTest.cs index 72091fb95efa..69a16f7e8af8 100644 --- a/tests/dotnet/UnitTests/WindowsTest.cs +++ b/tests/dotnet/UnitTests/WindowsTest.cs @@ -221,6 +221,25 @@ public void PluralRuntimeIdentifiersWithRemoteMac (ApplePlatform platform, strin DotNetProjectTest.PluralRuntimeIdentifiersImpl (platform, runtimeIdentifiers, properties); } + [Category ("RemoteWindows")] + [TestCase (ApplePlatform.iOS, "iossimulator-arm64")] + public void BuildEmbeddedFrameworkInBindingProjectApp (ApplePlatform platform, string runtimeIdentifiers) + { + var project = "EmbeddedFrameworkInBindingProjectApp"; + var configuration = "Debug"; + + Configuration.IgnoreIfIgnoredPlatform (platform); + Configuration.AssertRuntimeIdentifiersAvailable (platform, runtimeIdentifiers); + Configuration.IgnoreIfNotOnWindows (); + + var project_path = GetProjectPath (project, runtimeIdentifiers: runtimeIdentifiers, platform: platform, out var appPath, configuration: configuration); + Clean (project_path); + + var properties = GetDefaultProperties (runtimeIdentifiers); + + DotNet.AssertBuild (project_path, properties, timeout: TimeSpan.FromMinutes (15)); + } + static void AssertWarningsEqual (IList expected, IList actual, string message) { if (expected.Count == actual.Count) {