public void BuildBindingsTest2(string platform) { Configuration.IgnoreIfIgnoredPlatform(platform); var assemblyName = "bindings-test2"; var dotnet_bindings_dir = Path.Combine(Configuration.SourceRoot, "tests", assemblyName, "dotnet"); var project_dir = Path.Combine(dotnet_bindings_dir, platform); var project_path = Path.Combine(project_dir, $"{assemblyName}.csproj"); Clean(project_path); Configuration.CopyDotNetSupportingFiles(dotnet_bindings_dir); var result = DotNet.AssertBuild(project_path, verbosity); var lines = BinLog.PrintToLines(result.BinLogPath); // Find the resulting binding assembly from the build log var assemblies = FilterToAssembly(lines, assemblyName); Assert.That(assemblies, Is.Not.Empty, "Assemblies"); // Make sure there's no other assembly confusing our logic Assert.That(assemblies.Distinct().Count(), Is.EqualTo(1), "Unique assemblies"); var asm = assemblies.First(); Assert.That(asm, Does.Exist, "Assembly existence"); // Verify that there's one resource in the binding assembly, and its name var ad = AssemblyDefinition.ReadAssembly(asm, new ReaderParameters { ReadingMode = ReadingMode.Deferred }); Assert.That(ad.MainModule.Resources.Count, Is.EqualTo(1), "1 resource"); Assert.That(ad.MainModule.Resources [0].Name, Is.EqualTo("libtest2.a"), "libtest2.a"); }
public void BindingOldStyle(ApplePlatform platform) { var project = "BindingOldStyle"; Configuration.IgnoreIfIgnoredPlatform(platform); var project_path = GetProjectPath(project, platform: platform); Clean(project_path); Configuration.CopyDotNetSupportingFiles(Path.GetDirectoryName(project_path)); var tmpdir = Cache.CreateTemporaryDirectory(); var outputPath = Path.Combine(tmpdir, "OutputPath"); var intermediateOutputPath = Path.Combine(tmpdir, "IntermediateOutputPath"); var properties = GetDefaultProperties(); properties ["OutputPath"] = outputPath + Path.DirectorySeparatorChar; properties ["IntermediateOutputPath"] = intermediateOutputPath + Path.DirectorySeparatorChar; var rv = DotNet.AssertPackFailure(project_path, properties); var errors = BinLog.GetBuildLogErrors(rv.BinLogPath).ToArray(); Assert.AreEqual(1, errors.Length, "Error count"); Assert.AreEqual($"Creating a NuGet package is not supported for projects that have ObjcBindingNativeLibrary items. Migrate to use NativeReference items instead.", errors [0].Message, "Error message"); }
public void BuildBundledResources(string platform, string prefix) { Configuration.IgnoreIfIgnoredPlatform(platform); var assemblyName = "BundledResources"; var dotnet_bindings_dir = Path.Combine(Configuration.SourceRoot, "tests", assemblyName, "dotnet"); var project_dir = Path.Combine(dotnet_bindings_dir, platform); var project_path = Path.Combine(project_dir, $"{assemblyName}.csproj"); Clean(project_path); Configuration.CopyDotNetSupportingFiles(dotnet_bindings_dir); var result = DotNet.AssertBuild(project_path, verbosity); var lines = BinLog.PrintToLines(result.BinLogPath); // Find the resulting binding assembly from the build log var assemblies = FilterToAssembly(lines, assemblyName); Assert.That(assemblies, Is.Not.Empty, "Assemblies"); // Make sure there's no other assembly confusing our logic Assert.That(assemblies.Distinct().Count(), Is.EqualTo(1), "Unique assemblies"); var asm = assemblies.First(); Assert.That(asm, Does.Exist, "Assembly existence"); // Verify that there's one resource in the binding assembly, and its name var ad = AssemblyDefinition.ReadAssembly(asm, new ReaderParameters { ReadingMode = ReadingMode.Deferred }); Assert.That(ad.MainModule.Resources.Count, Is.EqualTo(2), "2 resources"); // Sort the resources before we assert, since we don't care about the order, and sorted order makes the asserts simpler. var resources = ad.MainModule.Resources.OrderBy(v => v.Name).ToArray(); Assert.That(resources [0].Name, Is.EqualTo($"__{prefix}_content_basn3p08.png"), $"__{prefix}_content_basn3p08.png"); Assert.That(resources [1].Name, Is.EqualTo($"__{prefix}_content_xamvideotest.mp4"), $"__{prefix}_content_xamvideotest.mp4"); }
public void BindingWithDefaultCompileInclude(ApplePlatform platform) { var project = "BindingWithDefaultCompileInclude"; Configuration.IgnoreIfIgnoredPlatform(platform); var project_path = GetProjectPath(project, platform: platform); Clean(project_path); var rv = DotNet.AssertBuild(project_path, GetDefaultProperties()); var dllPath = Path.Combine(Path.GetDirectoryName(project_path), "bin", "Debug", platform.ToFramework(), $"{project}.dll"); Assert.That(dllPath, Does.Exist, "Binding assembly"); // Verify that the MyNativeClass class exists in the assembly, and that it's actually a class. var ad = AssemblyDefinition.ReadAssembly(dllPath, new ReaderParameters { ReadingMode = ReadingMode.Deferred }); var myNativeClass = ad.MainModule.Types.FirstOrDefault(v => v.FullName == "MyApiDefinition.MyNativeClass"); Assert.IsFalse(myNativeClass.IsInterface, "IsInterface"); var myStruct = ad.MainModule.Types.FirstOrDefault(v => v.FullName == "MyClassLibrary.MyStruct"); Assert.IsTrue(myStruct.IsValueType, "MyStruct"); var warnings = BinLog.GetBuildLogWarnings(rv.BinLogPath).Select(v => v.Message); Assert.That(warnings, Is.Empty, $"Build warnings:\n\t{string.Join ("\n\t", warnings)}"); }
void AssertThatLinkerDidNotExecute(ExecutionResult result) { var output = BinLog.PrintToString(result.BinLogPath); Assert.That(output, Does.Not.Contain("Building target \"_RunILLink\" completely."), "Linker did not executed as expected."); Assert.That(output, Does.Not.Contain("LinkerConfiguration:"), "Custom steps did not run as expected."); }
public void BuildFSharpLibraryTest(string platform) { Configuration.IgnoreIfIgnoredPlatform(platform); var assemblyName = "fsharplibrary"; var dotnet_bindings_dir = Path.Combine(Configuration.SourceRoot, "tests", assemblyName, "dotnet"); var project_dir = Path.Combine(dotnet_bindings_dir, platform); var project_path = Path.Combine(project_dir, $"{assemblyName}.fsproj"); Clean(project_path); Configuration.CopyDotNetSupportingFiles(dotnet_bindings_dir); var result = DotNet.AssertBuild(project_path, verbosity); var lines = BinLog.PrintToLines(result.BinLogPath); // Find the resulting binding assembly from the build log var assemblies = FilterToAssembly(lines, assemblyName); Assert.That(assemblies, Is.Not.Empty, "Assemblies"); // Make sure there's no other assembly confusing our logic Assert.That(assemblies.Distinct().Count(), Is.EqualTo(1), "Unique assemblies"); var asm = assemblies.First(); Assert.That(asm, Does.Exist, "Assembly existence"); // Verify that there's no resources in the assembly var ad = AssemblyDefinition.ReadAssembly(asm, new ReaderParameters { ReadingMode = ReadingMode.Deferred }); Assert.That(ad.MainModule.Resources.Count(), Is.EqualTo(2), "2 resources"); // There are 2 embedded resources by default by the F# compiler. }
public void CreateAppBundleDependsOnTest(ApplePlatform platform) { Configuration.IgnoreIfIgnoredPlatform(platform); var magic = Guid.NewGuid().ToString(); var csproj = $@"<Project Sdk=""Microsoft.NET.Sdk""> <PropertyGroup> <TargetFramework>{platform.ToFramework ()}</TargetFramework> <OutputType>Exe</OutputType> <CreateAppBundleDependsOn>FailTheBuild;$(CreateAppBundleDependsOn)</CreateAppBundleDependsOn> </PropertyGroup> <Target Name=""FailTheBuild""> <Error Text=""{magic}"" /> </Target> </Project>"; var tmpdir = Cache.CreateTemporaryDirectory(); Configuration.CopyDotNetSupportingFiles(tmpdir); var project_path = Path.Combine(tmpdir, "TestProject.csproj"); File.WriteAllText(project_path, csproj); File.WriteAllText(Path.Combine(tmpdir, "Info.plist"), EmptyAppManifest); File.WriteAllText(Path.Combine(tmpdir, "Main.cs"), EmptyMainFile); var properties = GetDefaultProperties(); var result = DotNet.AssertBuildFailure(project_path, properties); var errors = BinLog.GetBuildLogErrors(result.BinLogPath); Assert.That(errors, Has.Some.Matches <BuildLogEvent> (v => v.Message.Contains(magic)), "Expected error"); }
public void PublishFailureTest(ApplePlatform platform, string runtimeIdentifiers) { var project = "MySimpleApp"; Configuration.IgnoreIfIgnoredPlatform(platform); var project_path = GetProjectPath(project, runtimeIdentifiers, platform: platform, out var appPath); Clean(project_path); string packageExtension; string pathVariable; switch (platform) { case ApplePlatform.iOS: case ApplePlatform.TVOS: packageExtension = "ipa"; pathVariable = "IpaPackagePath"; break; case ApplePlatform.MacCatalyst: case ApplePlatform.MacOSX: packageExtension = "pkg"; pathVariable = "PkgPackagePath"; break; default: throw new ArgumentOutOfRangeException($"Unknown platform: {platform}"); } var tmpdir = Cache.CreateTemporaryDirectory(); var pkgPath = Path.Combine(tmpdir, $"MyPackage.{packageExtension}"); var properties = GetDefaultProperties(runtimeIdentifiers); properties [pathVariable] = pkgPath; var rv = DotNet.AssertPublishFailure(project_path, properties); var errors = BinLog.GetBuildLogErrors(rv.BinLogPath).ToArray(); Assert.AreEqual(1, errors.Length, "Error Count"); string expectedErrorMessage; if (string.IsNullOrEmpty(runtimeIdentifiers)) { expectedErrorMessage = $"A runtime identifier must be specified in order to publish this project."; } else if (runtimeIdentifiers.IndexOf(';') >= 0) { expectedErrorMessage = $"A runtime identifier for a device architecture must be specified in order to publish this project. '{runtimeIdentifiers}' are simulator architectures."; } else { expectedErrorMessage = $"A runtime identifier for a device architecture must be specified in order to publish this project. '{runtimeIdentifiers}' is a simulator architecture."; } Assert.AreEqual(expectedErrorMessage, errors [0].Message, "Error Message"); Assert.That(pkgPath, Does.Not.Exist, "ipa/pkg creation"); }
// [TestCase ("watchOS")] // No watchOS Touch.Client project for .NET yet // [TestCase ("macOS")] // No macOS Touch.Client project for .NET yet public void BuildInterdependentBindingProjects (string platform) { Configuration.IgnoreIfIgnoredPlatform (platform); var assemblyName = "interdependent-binding-projects"; var dotnet_bindings_dir = Path.Combine (Configuration.SourceRoot, "tests", assemblyName, "dotnet"); var project_dir = Path.Combine (dotnet_bindings_dir, platform); var project_path = Path.Combine (project_dir, $"{assemblyName}.csproj"); Clean (project_path); 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")); try { var result = DotNet.AssertBuild (project_path, verbosity); var lines = BinLog.PrintToLines (result.BinLogPath); // Find the resulting binding assembly from the build log var assemblies = lines. Select (v => v.Trim ()). Where (v => { if (v.Length < 10) return false; if (v [0] != '/') return false; if (!v.EndsWith ($"{assemblyName}.dll", StringComparison.Ordinal)) return false; if (!v.Contains ("/bin/", StringComparison.Ordinal)) return false; if (!v.Contains ($"{assemblyName}.app", StringComparison.Ordinal)) return false; return true; }); Assert.That (assemblies, Is.Not.Empty, "Assemblies"); // Make sure there's no other assembly confusing our logic assemblies = assemblies.Distinct (); Assert.That (assemblies.Count (), Is.EqualTo (1), $"Unique assemblies: {string.Join (", ", assemblies)}"); var asm = assemblies.First (); Assert.That (asm, Does.Exist, "Assembly existence"); // Verify that the resources have been linked away var asmDir = Path.GetDirectoryName (asm); var ad = AssemblyDefinition.ReadAssembly (asm, new ReaderParameters { ReadingMode = ReadingMode.Deferred }); Assert.That (ad.MainModule.Resources.Count, Is.EqualTo (0), "0 resources for interdependent-binding-projects.dll"); var ad1 = AssemblyDefinition.ReadAssembly (Path.Combine (asmDir, "bindings-test.dll"), new ReaderParameters { ReadingMode = ReadingMode.Deferred }); // The native library is removed from the resources by the linker Assert.That (ad1.MainModule.Resources.Count, Is.EqualTo (0), "0 resources for bindings-test.dll"); var ad2 = AssemblyDefinition.ReadAssembly (Path.Combine (asmDir, "bindings-test2.dll"), new ReaderParameters { ReadingMode = ReadingMode.Deferred }); // The native library is removed from the resources by the linker Assert.That (ad2.MainModule.Resources.Count, Is.EqualTo (0), "0 resources for bindings-test2.dll"); } finally { foreach (var file in cleanupSupportFiles) File.Delete (file); } }
public void CreateAndBuildTemplate(TemplateInfo info) { if (!info.ValidateSuccessfulBuild) { return; } Configuration.IgnoreIfIgnoredPlatform(info.Platform); var tmpDir = Cache.CreateTemporaryDirectory(); Configuration.CopyDotNetSupportingFiles(tmpDir); var outputDir = Path.Combine(tmpDir, info.Template); DotNet.AssertNew(outputDir, info.Template); var csproj = Path.Combine(outputDir, info.Template + ".csproj"); var rv = DotNet.AssertBuild(csproj); var warnings = BinLog.GetBuildLogWarnings(rv.BinLogPath).Select(v => v.Message); Assert.That(warnings, Is.Empty, $"Build warnings:\n\t{string.Join ("\n\t", warnings)}"); if (info.Execute) { var platform = info.Platform; var runtimeIdentifiers = GetDefaultRuntimeIdentifier(platform); Assert.IsTrue(CanExecute(info.Platform, runtimeIdentifiers), "Must be executable to execute!"); // First add some code to exit the template if it launches successfully. var mainFile = Path.Combine(outputDir, "Main.cs"); var mainContents = File.ReadAllText(mainFile); var exitSampleWithSuccess = @"NSTimer.CreateScheduledTimer (1, (v) => { Console.WriteLine (Environment.GetEnvironmentVariable (""MAGIC_WORD"")); Environment.Exit (0); }); " ; var modifiedMainContents = mainContents.Replace("// This is the main entry point of the application.", exitSampleWithSuccess); Assert.AreNotEqual(modifiedMainContents, mainContents, "Failed to modify the main content"); File.WriteAllText(mainFile, modifiedMainContents); // Build the sample rv = DotNet.AssertBuild(csproj); // There should still not be any warnings warnings = BinLog.GetBuildLogWarnings(rv.BinLogPath).Select(v => v.Message); Assert.That(warnings, Is.Empty, $"Build warnings (2):\n\t{string.Join ("\n\t", warnings)}"); var appPath = GetAppPath(csproj, platform, runtimeIdentifiers); var appExecutable = GetNativeExecutable(platform, appPath); ExecuteWithMagicWordAndAssert(appExecutable); } }
public void CreateAndBuildTemplate(string platform, string template) { Configuration.IgnoreIfIgnoredPlatform(platform); var tmpDir = Cache.CreateTemporaryDirectory(); Configuration.CopyDotNetSupportingFiles(tmpDir); var outputDir = Path.Combine(tmpDir, template); DotNet.AssertNew(outputDir, template); var csproj = Path.Combine(outputDir, template + ".csproj"); var rv = DotNet.AssertBuild(csproj); var warnings = BinLog.GetBuildLogWarnings(rv.BinLogPath).Select(v => v.Message); Assert.That(warnings, Is.Empty, $"Build warnings:\n\t{string.Join ("\n\t", warnings)}"); }
public void NativeLink(ApplePlatform platform, string runtimeIdentifiers) { Configuration.IgnoreIfIgnoredPlatform(platform); var project_path = GenerateProject(platform, name: nameof(NativeLink), runtimeIdentifiers: runtimeIdentifiers, out var appPath); var properties = new Dictionary <string, string> (verbosity); SetRuntimeIdentifiers(properties, runtimeIdentifiers); var mainContents = @" class MainClass { static int Main () { return 123; } } "; var mainFile = Path.Combine(Path.GetDirectoryName(project_path), "Main.cs"); File.WriteAllText(mainFile, mainContents); // Build the first time var rv = DotNet.AssertBuild(project_path, properties); var allTargets = BinLog.GetAllTargets(rv.BinLogPath); AssertTargetExecuted(allTargets, "_AOTCompile", "A"); AssertTargetExecuted(allTargets, "_CompileNativeExecutable", "A"); AssertTargetExecuted(allTargets, "_LinkNativeExecutable", "A"); // Capture the current time var timestamp = DateTime.UtcNow; File.WriteAllText(mainFile, mainContents + "\n"); // Build again rv = DotNet.AssertBuild(project_path, properties); // Check that some targets executed allTargets = BinLog.GetAllTargets(rv.BinLogPath); AssertTargetExecuted(allTargets, "_AOTCompile", "B"); AssertTargetNotExecuted(allTargets, "_CompileNativeExecutable", "B"); AssertTargetExecuted(allTargets, "_LinkNativeExecutable", "B"); // Verify that the timestamp of the executable has been updated var executable = GetNativeExecutable(platform, appPath); Assert.That(File.GetLastWriteTimeUtc(executable), Is.GreaterThan(timestamp), "B: Executable modified"); }
[TestCase(ApplePlatform.MacCatalyst, "osx-x64")] // valid RID for another platform public void InvalidRuntimeIdentifier(ApplePlatform platform, string runtimeIdentifier) { var project = "MySimpleApp"; Configuration.IgnoreIfIgnoredPlatform(platform); var project_path = GetProjectPath(project, platform: platform); Clean(project_path); 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"); }
public void InvalidRuntimeIdentifiers(ApplePlatform platform, string runtimeIdentifiers) { var project = "MySimpleApp"; Configuration.IgnoreIfIgnoredPlatform(platform); var project_path = GetProjectPath(project, platform: platform); Clean(project_path); var properties = GetDefaultProperties(runtimeIdentifiers); var rv = DotNet.AssertBuildFailure(project_path, properties); var errors = BinLog.GetBuildLogErrors(rv.BinLogPath).ToArray(); Assert.AreEqual(1, errors.Length, "Error count"); Assert.AreEqual($"Building for all the runtime identifiers '{runtimeIdentifiers}' at the same time isn't possible, because they represent different platform variations.", errors [0].Message, "Error message"); }
[TestCase(ApplePlatform.MacCatalyst, "osx-x64")] // valid RID for another platform public void InvalidRuntimeIdentifier(ApplePlatform platform, string runtimeIdentifier) { var project = "MySimpleApp"; Configuration.IgnoreIfIgnoredPlatform(platform); var project_path = GetProjectPath(project, platform: platform); Clean(project_path); var properties = new Dictionary <string, string> (verbosity); properties ["RuntimeIdentifier"] = runtimeIdentifier; var rv = DotNet.AssertBuildFailure(project_path, properties); var errors = BinLog.GetBuildMessages(rv.BinLogPath).Where(v => v.Type == BuildLogEventType.Error).ToArray(); Assert.AreEqual(1, errors.Length, "Error count"); Assert.AreEqual($"The RuntimeIdentifier '{runtimeIdentifier}' is invalid.", errors [0].Message, "Error message"); }
public void DisableLinker(ApplePlatform platform, string runtimeIdentifiers) { var project = "MySimpleApp"; Configuration.IgnoreIfIgnoredPlatform(platform); var project_path = GetProjectPath(project, platform: platform); Clean(project_path); var properties = GetDefaultProperties(runtimeIdentifiers); properties ["PublishTrimmed"] = "false"; var rv = DotNet.AssertBuildFailure(project_path, properties); var errors = BinLog.GetBuildLogErrors(rv.BinLogPath).ToArray(); Assert.AreEqual(1, errors.Length, "Error count"); Assert.AreEqual($"{platform.AsString ()} projects must build with PublishTrimmed=true. Current value: false.", errors [0].Message, "Error message"); }
public void FilesInAppBundle(ApplePlatform platform, string runtimeIdentifiers) { var project = "MySimpleApp"; Configuration.IgnoreIfIgnoredPlatform(platform); var project_path = GetProjectPath(project, runtimeIdentifiers: runtimeIdentifiers, platform: platform, out var appPath); Clean(project_path); var properties = GetDefaultProperties(runtimeIdentifiers); // Build DotNet.AssertBuild(project_path, properties); // Simulate a crash dump File.WriteAllText(Path.Combine(appPath, "mono_crash.mem.123456.something.blob"), "A crash dump"); File.WriteAllText(Path.Combine(appPath, "mono_crash.123456.somethingelse.blob"), "A crash dump"); // Build again DotNet.AssertBuild(project_path, properties); // Create a file that isn't a crash report. File.WriteAllText(Path.Combine(appPath, "otherfile.txt"), "A file"); // Build again - this time it'll fail var rv = DotNet.Build(project_path, properties); var warnings = BinLog.GetBuildLogWarnings(rv.BinLogPath).ToArray(); Assert.AreNotEqual(0, rv.ExitCode, "Unexpected success"); Assert.AreEqual(1, warnings.Length, "Warning Count"); Assert.AreEqual("Found files in the root directory of the app bundle. This will likely cause codesign to fail. Files:\nbin/Debug/net6.0-maccatalyst/maccatalyst-x64/MySimpleApp.app/otherfile.txt", warnings [0].Message, "Warning"); // Remove the offending file File.Delete(Path.Combine(appPath, "otherfile.txt")); // Build yet again DotNet.AssertBuild(project_path, properties); }
public void Build(ApplePlatform platform, string runtimeIdentifiers, CodeSignature signature, string configuration) { var project = "BundleStructure"; Configuration.IgnoreIfIgnoredPlatform(platform); var project_path = GetProjectPath(project, runtimeIdentifiers: runtimeIdentifiers, platform: platform, out var appPath, configuration: configuration); var project_dir = Path.GetDirectoryName(Path.GetDirectoryName(project_path)) !; Clean(project_path); var properties = GetDefaultProperties(runtimeIdentifiers); properties ["_IsAppSigned"] = signature != CodeSignature.None ? "true" : "false"; if (!string.IsNullOrWhiteSpace(configuration)) { properties ["Configuration"] = configuration; } var rv = DotNet.AssertBuild(project_path, properties); var warnings = BinLog.GetBuildLogWarnings(rv.BinLogPath).ToArray(); var warningMessages = FilterWarnings(warnings); var isReleaseBuild = string.Equals(configuration, "Release", StringComparison.OrdinalIgnoreCase); var platformString = platform.AsString(); var tfm = platform.ToFramework(); var testsDirectory = Path.GetDirectoryName(Path.GetDirectoryName(project_dir)); var expectedWarnings = new string [] { $"The 'PublishFolderType' metadata value 'Unknown' on the item '{project_dir}/{platformString}/SomewhatUnknownI.bin' is not recognized. The file will not be copied to the app bundle. If the file is not supposed to be copied to the app bundle, remove the 'CopyToOutputDirectory' metadata on the item.", $"The 'PublishFolderType' metadata value 'Unknown' on the item '{project_dir}/{platformString}/UnknownI.bin' is not recognized. The file will not be copied to the app bundle. If the file is not supposed to be copied to the app bundle, remove the 'CopyToOutputDirectory' metadata on the item.", $"The file '{project_dir}/{platformString}/NoneA.txt' does not specify a 'PublishFolderType' metadata, and a default value could not be calculated. The file will not be copied to the app bundle.", $"The file '{project_dir}/{platformString}/NoneI.txt' does not specify a 'PublishFolderType' metadata, and a default value could not be calculated. The file will not be copied to the app bundle.", $"The file '{project_dir}/{platformString}/NoneJ.txt' does not specify a 'PublishFolderType' metadata, and a default value could not be calculated. The file will not be copied to the app bundle.", $"The file '{project_dir}/{platformString}/NoneK.txt' does not specify a 'PublishFolderType' metadata, and a default value could not be calculated. The file will not be copied to the app bundle.", $"The file '{project_dir}/{platformString}/NoneM.unknown' does not specify a 'PublishFolderType' metadata, and a default value could not be calculated. The file will not be copied to the app bundle.", $"The file '{project_dir}/{platformString}/Sub/NoneG.txt' does not specify a 'PublishFolderType' metadata, and a default value could not be calculated. The file will not be copied to the app bundle.", $"The file '{project_dir}/NoneH.txt' does not specify a 'PublishFolderType' metadata, and a default value could not be calculated. The file will not be copied to the app bundle.", }.ToList(); var rids = runtimeIdentifiers.Split(';'); if (rids.Length > 1) { // All warnings show up twice if we're building for multiple architectures expectedWarnings.AddRange(expectedWarnings); } var zippedFrameworks = platform == ApplePlatform.MacCatalyst || platform == ApplePlatform.MacOSX; foreach (var rid in rids) { if (zippedFrameworks) { expectedWarnings.Add($"The framework obj/{configuration}/{tfm}/{rid}/bindings-framework-test.resources.zip/XStaticObjectTest.framework is a framework of static libraries, and will not be copied to the app."); expectedWarnings.Add($"The framework obj/{configuration}/{tfm}/{rid}/bindings-framework-test.resources.zip/XStaticArTest.framework is a framework of static libraries, and will not be copied to the app."); } else { expectedWarnings.Add($"The framework {testsDirectory}/bindings-framework-test/dotnet/{platformString}/bin/{configuration}/{tfm}/bindings-framework-test.resources/XStaticObjectTest.framework is a framework of static libraries, and will not be copied to the app."); expectedWarnings.Add($"The framework {testsDirectory}/bindings-framework-test/dotnet/{platformString}/bin/{configuration}/{tfm}/bindings-framework-test.resources/XStaticArTest.framework is a framework of static libraries, and will not be copied to the app."); } } if (signature == CodeSignature.None && (platform == ApplePlatform.MacCatalyst || platform == ApplePlatform.MacOSX)) { expectedWarnings.Add($"Found files in the root directory of the app bundle. This will likely cause codesign to fail. Files:\nbin/{configuration}/{tfm}{(runtimeIdentifiers.IndexOf (';') >= 0 ? string.Empty : "/" + runtimeIdentifiers)}/BundleStructure.app/UnknownJ.bin"); } // Sort the messages so that comparison against the expected array is faster expectedWarnings = expectedWarnings .OrderBy(v => v) .ToList(); var appExecutable = GetNativeExecutable(platform, appPath); CheckAppBundleContents(platform, appPath, rids, signature, isReleaseBuild); CollectionAssert.AreEqual(expectedWarnings, warningMessages, "Warnings"); ExecuteWithMagicWordAndAssert(platform, runtimeIdentifiers, appExecutable); // touch AppDelegate.cs, and rebuild should succeed and do the right thing var appDelegatePath = Path.Combine(project_dir, "AppDelegate.cs"); Configuration.Touch(appDelegatePath); rv = DotNet.AssertBuild(project_path, properties); warnings = BinLog.GetBuildLogWarnings(rv.BinLogPath).ToArray(); warningMessages = FilterWarnings(warnings); CheckAppBundleContents(platform, appPath, rids, signature, isReleaseBuild); CollectionAssert.AreEqual(expectedWarnings, warningMessages, "Warnings Rebuild 1"); ExecuteWithMagicWordAndAssert(platform, runtimeIdentifiers, appExecutable); // remove the bin directory, and rebuild should succeed and do the right thing var binDirectory = Path.Combine(Path.GetDirectoryName(project_path) !, "bin"); Directory.Delete(binDirectory, true); rv = DotNet.AssertBuild(project_path, properties); warnings = BinLog.GetBuildLogWarnings(rv.BinLogPath).ToArray(); warningMessages = FilterWarnings(warnings); CheckAppBundleContents(platform, appPath, rids, signature, isReleaseBuild); CollectionAssert.AreEqual(expectedWarnings, warningMessages, "Warnings Rebuild 2"); ExecuteWithMagicWordAndAssert(platform, runtimeIdentifiers, appExecutable); // a simple rebuild should succeed rv = DotNet.AssertBuild(project_path, properties); warnings = BinLog.GetBuildLogWarnings(rv.BinLogPath).ToArray(); warningMessages = FilterWarnings(warnings); CheckAppBundleContents(platform, appPath, rids, signature, isReleaseBuild); CollectionAssert.AreEqual(expectedWarnings, warningMessages, "Warnings Rebuild 3"); ExecuteWithMagicWordAndAssert(platform, runtimeIdentifiers, appExecutable); }