Example #1
0
        public void MM0176(bool xm45, string tfv)
        {
            RunMMPTest(tmpDir => {
                var test = new TI.UnifiedTestConfig(tmpDir)
                {
                    References = "<PackageReference Include=\"xunit.runner.utility\" Version=\"2.4.0\" />",
                    TestCode   = "System.Console.WriteLine (typeof (Xunit.AfterTestFinished));",
                    XM45       = xm45,
                };
                if (tfv != null)
                {
                    test.TargetFrameworkVersion = $"<TargetFrameworkVersion>{tfv}</TargetFrameworkVersion>";
                }

                string project = TI.GenerateUnifiedExecutableProject(test);
                TI.NugetRestore(project);
                var rv = new OutputText(TI.BuildProject(project), string.Empty);
                Console.WriteLine(rv.BuildResult);
                if (xm45)
                {
                    var referenced_version = tfv == null ? "2.0.0.0" : "4.0.0.0";
                    rv.Messages.AssertWarningPattern(176, $"The assembly 'System.Web, Version={referenced_version}, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' was resolved from the system's GAC: /Library/Frameworks/Mono.framework/Versions/.*/lib/mono/gac/System.Web/4.0.0.0__b03f5f7f11d50a3a/System.Web.dll. This could potentially be a problem in the future; to avoid such problems, please make sure to not use assemblies only available in the system's GAC.");
                    rv.Messages.AssertWarningPattern(176, $"The assembly 'System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' was resolved from the system's GAC: /Library/Frameworks/Mono.framework/Versions/.*/lib/mono/gac/System.Drawing/4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll. This could potentially be a problem in the future; to avoid such problems, please make sure to not use assemblies only available in the system's GAC.");
                    rv.Messages.AssertWarningPattern(176, $"The assembly 'System.Web.ApplicationServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' was resolved from the system's GAC: /Library/Frameworks/Mono.framework/Versions/.*/lib/mono/gac/System.Web.ApplicationServices/4.0.0.0__31bf3856ad364e35/System.Web.ApplicationServices.dll. This could potentially be a problem in the future; to avoid such problems, please make sure to not use assemblies only available in the system's GAC.");
                    // Don't assert number of warnings, because we get a few "MM2006: Native library 'foo.dll' was referenced but could not be found." warnings as well.
                }
                else
                {
                    rv.Messages.AssertWarningCount(0);
                }
            });
        }
Example #2
0
        public void BuildingSameSolutionTwice_ShouldNotRunACToolTwice()
        {
            Func <string, bool> executedActool = (line) => {
                if (!line.Contains(" execution started with arguments"))
                {
                    return(false);
                }
                return(line.Contains("actool --errors --warnings --notices --output-format xml1 --output-partial-info-plist "));
            };

            RunMMPTest(tmpDir => {
                TI.UnifiedTestConfig test = new TI.UnifiedTestConfig(tmpDir)
                {
                    AssetIcons = true
                };

                string project = TI.GenerateUnifiedExecutableProject(test);

                var buildResult = TI.BuildProject(project);
                Assert.True(buildResult.BuildOutputLines.Any(executedActool), $"Initial build should run actool");

                buildResult = TI.BuildProject(project);
                Assert.False(buildResult.BuildOutputLines.Any(executedActool), $"Second build should not run actool");

                TI.RunAndAssert("touch", new [] { Path.Combine(tmpDir, "Assets.xcassets/AppIcon.appiconset/[email protected]") }, "touch icon");

                buildResult = TI.BuildProject(project);
                Assert.True(buildResult.BuildOutputLines.Any(executedActool), $"Build after touching icon must run actool");
            });
        }
        public void NativeExtensionEmbedding(bool XM45)
        {
            MMPTests.RunMMPTest(tmpDir => {
                TI.CopyDirectory(Path.Combine(TI.FindSourceDirectory(), @"NativeExtension"), tmpDir);

                var xcodeProjectFolder   = Path.Combine(tmpDir, "NativeExtension");
                string [] xcodeBuildArgs = new [] { "-configuration", "Debug", "-target", "NativeTodayExtension", "-arch", "x86_64" };
                var env = new System.Collections.Generic.Dictionary <string, string> {
                    { "DEVELOPER_DIR", Configuration.XcodeLocation }
                };
                Assert.AreEqual(0, ExecutionHelper.Execute("/usr/bin/xcodebuild", xcodeBuildArgs.Concat(new [] { "clean" }).ToArray(), out var _, workingDirectory: xcodeProjectFolder, environment_variables: env, stdout_callback: Console.WriteLine, stderr_callback: Console.Error.WriteLine));
                Assert.AreEqual(0, ExecutionHelper.Execute("/usr/bin/xcodebuild", xcodeBuildArgs.Concat(new [] { "build" }).ToArray(), out var _, workingDirectory: xcodeProjectFolder, environment_variables: env, stdout_callback: Console.WriteLine, stderr_callback: Console.Error.WriteLine));

                var items = @"
<ItemGroup>
	<AdditionalAppExtensions Include=""$(MSBuildProjectDirectory)/NativeExtension"">
		<Name>NativeTodayExtension</Name>
		<BuildOutput>build/Debug</BuildOutput>
	</AdditionalAppExtensions>
</ItemGroup>";

                var config = new TI.UnifiedTestConfig(tmpDir)
                {
                    XM45 = XM45, ItemGroup = items
                };
                string csprojTarget = TI.GenerateUnifiedExecutableProject(config);
                TI.BuildProject(csprojTarget);

                Assert.That(File.Exists(Path.Combine(tmpDir, "bin", "Debug", (XM45 ? "XM45Example.app" : "UnifiedExample.app"), "Contents", "PlugIns", "NativeTodayExtension.appex", "Contents", "MacOS", "NativeTodayExtension")), "NativeTodayExtension");
            });
        }
Example #4
0
        public void Unified_FailedBuild_ShouldRequireAnotherBuildNotSkipMMP()
        {
            RunMMPTest(tmpDir => {
                foreach (bool xm45 in new bool [] { false, true })
                {
                    // First build with a Non-existant file to force us to error inside mmp test
                    TI.UnifiedTestConfig test = new TI.UnifiedTestConfig(tmpDir)
                    {
                        CSProjConfig = "<MonoBundlingExtraArgs>--resource=Foo.bar</MonoBundlingExtraArgs>", XM45 = xm45
                    };
                    TI.GenerateAndBuildUnifiedExecutable(test, shouldFail: true);

                    // Next, build again without the error MonoBundlingExtraArgs
                    test.CSProjConfig = "";
                    TI.GenerateUnifiedExecutableProject(test);

                    // And try again.
                    // If we fail, we'll likely fail with "did not generate an exe" before returning but let's check anyway
                    var secondBuildResult = TI.BuildProject(Path.Combine(tmpDir, TI.GetUnifiedExecutableProjectName(test)));
                    var secondBuildOutput = secondBuildResult.BuildOutput;
                    Assert.IsTrue(!secondBuildOutput.Contains("Skipping target \"_CompileToNative"), "Did not skip");
                    Assert.IsTrue(secondBuildOutput.Contains("Building target \"_CompileToNative\" completely"), "Did need to build");
                }
            });
        }
Example #5
0
        public void MultipleDependencyChain(bool useProjectReference)
        {
            // App can depend on Lib that depends on binding lib with native reference and everything gets packaged in correctly
            MMPTests.RunMMPTest(tmpDir => {
                TI.UnifiedTestConfig binding = new TI.UnifiedTestConfig(tmpDir)
                {
                    ProjectName = "MobileBinding.csproj"
                };
                binding.ItemGroup           += NativeReferenceTests.CreateSingleNativeRef(NativeReferenceTests.SimpleDylibPath, "Dynamic");
                binding.APIDefinitionConfig += @"[BaseType (typeof (NSObject))]
  interface SimpleClass {
    [Export (""doIt"")]
    int DoIt ();
  }";
                BindingProjectTests.SetNoEmbedding(binding);

                TI.GenerateBindingLibraryProject(binding);
                TI.BuildProject(Path.Combine(tmpDir, "MobileBinding.csproj"), true);


                TI.UnifiedTestConfig library = new TI.UnifiedTestConfig(tmpDir)
                {
                    ProjectName = "UnifiedLibrary"
                };
                library.TestCode = "public class MyClass { public static void Go () { var c = new ExampleBinding.SimpleClass (); c.DoIt (); } }";

                if (useProjectReference)
                {
                    library.References = $@"<ProjectReference Include=""MobileBinding.csproj"" />";
                }
                else
                {
                    library.References = $@"<Reference Include=""MobileBinding""><HintPath>{Path.Combine (tmpDir, "bin/Debug", "MobileBinding.dll")}</HintPath></Reference>";
                }

                TI.GenerateUnifiedLibraryProject(library);
                TI.BuildProject(Path.Combine(tmpDir, "UnifiedLibrary.csproj"), true);

                TI.UnifiedTestConfig project = new TI.UnifiedTestConfig(tmpDir)
                {
                    ProjectName = "UnifiedExample.csproj"
                };
                project.TestCode = "MyClass.Go ();";

                if (useProjectReference)
                {
                    project.References = $@"<ProjectReference Include=""UnifiedLibrary.csproj"" />";
                }
                else
                {
                    project.References = $@"<Reference Include=""UnifiedLibrary""><HintPath>{Path.Combine (tmpDir, "bin/Debug", "UnifiedLibrary.dll")}</HintPath></Reference>";
                }

                TI.GenerateUnifiedExecutableProject(project);
                TI.BuildProject(Path.Combine(tmpDir, "UnifiedExample.csproj"), true);
            });
        }
        // [TestCase (true)] https://github.com/xamarin/xamarin-macios/issues/4110
        // [TestCase (false)] https://github.com/xamarin/xamarin-macios/issues/4110
        public void AppsWithPackageReferencs_BuildAndRun(bool full)
        {
            MMPTests.RunMMPTest(tmpDir => {
                var config = new TI.UnifiedTestConfig(tmpDir)
                {
                    ItemGroup = PackageReference,
                    TestCode  = TestCode + @"			if (output == ""[1,2,3]"")
				"                ,
                    XM45      = full
                };
                TI.AddGUIDTestCode(config);

                string project = TI.GenerateUnifiedExecutableProject(config);
                TI.NugetRestore(project);
                TI.BuildProject(project, true);
                TI.RunGeneratedUnifiedExecutable(config);
            });
        }
Example #7
0
        // context https://github.com/xamarin/xamarin-macios/issues/7113
        public void SatellitesFromNuget(bool full)
        {
            MMPTests.RunMMPTest(tmpDir => {
                var config = new TI.UnifiedTestConfig(tmpDir)
                {
                    ItemGroup = @"<ItemGroup><PackageReference Include = ""Humanizer"" Version = ""2.7.2"" /></ItemGroup>",
                    TestCode  = "Humanizer.DateHumanizeExtensions.Humanize (System.DateTime.UtcNow.AddHours (-30));\n",
                    XM45      = full
                };
                TI.AddGUIDTestCode(config);

                string project = TI.GenerateUnifiedExecutableProject(config);
                TI.NugetRestore(project);
                TI.BuildProject(project);

                var appDir = Path.Combine(tmpDir, "bin", "Debug", full ? "XM45Example.app" : "UnifiedExample.app");
                Assert.True(File.Exists(Path.Combine(appDir, "Contents", "MonoBundle", "fr", "Humanizer.resources.dll")), "fr");
            });
        }
Example #8
0
        public void BuildingSameSolutionTwice_ShouldNotRunACToolTwice()
        {
            RunMMPTest(tmpDir => {
                TI.UnifiedTestConfig test = new TI.UnifiedTestConfig(tmpDir)
                {
                    AssetIcons = true
                };

                string project = TI.GenerateUnifiedExecutableProject(test);

                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);
                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/[email protected]"), "touch icon");

                buildOutput = TI.BuildProject(project, true);
                Assert.True(buildOutput.Contains("actool execution started with arguments"), $"Build after touching icon must run actool");
            });
        }
Example #9
0
        public void BuildingSameSolutionTwice_ShouldNotRunACToolTwice()
        {
            const string actool = " execution started with arguments: actool --errors --warnings --notices --output-format xml1 --output-partial-info-plist ";

            RunMMPTest(tmpDir => {
                TI.UnifiedTestConfig test = new TI.UnifiedTestConfig(tmpDir)
                {
                    AssetIcons = true
                };

                string project = TI.GenerateUnifiedExecutableProject(test);

                string buildOutput = TI.BuildProject(project);
                Assert.True(buildOutput.Contains(actool), $"Initial build should run actool");

                buildOutput = TI.BuildProject(project);
                Assert.False(buildOutput.Contains(actool), $"Second build should not run actool");

                TI.RunAndAssert("touch", new [] { Path.Combine(tmpDir, "Assets.xcassets/AppIcon.appiconset/[email protected]") }, "touch icon");

                buildOutput = TI.BuildProject(project);
                Assert.True(buildOutput.Contains(actool), $"Build after touching icon must run actool");
            });
        }