コード例 #1
0
        public void AllProjectsHaveSameOutputDirectory()
        {
            var testPath = Path.Combine("temp", "AllProjectsHaveSameOutputDirectory");
            var sb       = new SolutionBuilder("AllProjectsHaveSameOutputDirectory.sln")
            {
                SolutionPath = Path.Combine(Root, testPath),
                Verbosity    = LoggerVerbosity.Diagnostic,
            };

            var app1 = new XamarinAndroidApplicationProject()
            {
                ProjectName = "App1",
                OutputPath  = Path.Combine("..", "bin", "Debug"),
            };

            sb.Projects.Add(app1);
            var app2 = new XamarinAndroidApplicationProject()
            {
                ProjectName = "App2",
                OutputPath  = Path.Combine("..", "bin", "Debug"),
            };

            sb.Projects.Add(app2);
            Assert.IsTrue(sb.Build(), "Build of solution should have succeeded");
            Assert.IsTrue(sb.ReBuild(), "ReBuild of solution should have succeeded");
            sb.Dispose();
        }
コード例 #2
0
        public void BuildAMassiveApp()
        {
            var testPath = Path.Combine("temp", "BuildAMassiveApp");

            TestOutputDirectories [TestContext.CurrentContext.Test.ID] = Path.Combine(Root, testPath);
            var sb = new SolutionBuilder("BuildAMassiveApp.sln")
            {
                SolutionPath = Path.Combine(Root, testPath),
            };
            var app1 = new XamarinFormsMapsApplicationProject {
                TargetFrameworkVersion = sb.LatestTargetFrameworkVersion(),
                ProjectName            = "App1",
                AotAssemblies          = true,
                IsRelease = true,
            };

            //NOTE: BuildingInsideVisualStudio prevents the projects from being built as dependencies
            sb.BuildingInsideVisualStudio = false;
            app1.Imports.Add(new Import("foo.targets")
            {
                TextContent = () => @"<?xml version=""1.0"" encoding=""utf-16""?>
<Project ToolsVersion=""4.0"" xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<Target Name=""_CheckAbis"" BeforeTargets=""_DefineBuildTargetAbis"">
	<PropertyGroup>
		<AndroidSupportedAbis>armeabi-v7a;x86</AndroidSupportedAbis>
		<AndroidSupportedAbis Condition=""Exists('$(MSBuildThisFileDirectory)..\..\..\..\Debug\lib\xamarin.android\xbuild\Xamarin\Android\lib\arm64-v8a\libmono-android.release.so')"">$(AndroidSupportedAbis);arm64-v8a</AndroidSupportedAbis>
		<AndroidSupportedAbis Condition=""Exists('$(MSBuildThisFileDirectory)..\..\..\..\Debug\lib\xamarin.android\xbuild\Xamarin\Android\lib\x86_64\libmono-android.release.so')"">$(AndroidSupportedAbis);x86_64</AndroidSupportedAbis>
	</PropertyGroup>
	<Message Text=""$(AndroidSupportedAbis)"" />
</Target>
<Target Name=""_Foo"" AfterTargets=""_SetLatestTargetFrameworkVersion"">
	<PropertyGroup>
		<AotAssemblies Condition=""!Exists('$(MonoAndroidBinDirectory)"         + Path.DirectorySeparatorChar + @"cross-arm')"">False</AotAssemblies>
	</PropertyGroup>
	<Message Text=""$(AotAssemblies)"" />
</Target>
</Project>
",
            });
            sb.Projects.Add(app1);
            var code = new StringBuilder();

            code.AppendLine("using System;");
            code.AppendLine("namespace App1 {");
            code.AppendLine("\tpublic class AppCode {");
            code.AppendLine("\t\tpublic void Foo () {");
            for (int i = 0; i < 128; i++)
            {
                var libName = $"Lib{i}";
                var lib     = new XamarinAndroidLibraryProject()
                {
                    TargetFrameworkVersion = sb.LatestTargetFrameworkVersion(),
                    ProjectName            = libName,
                    IsRelease       = true,
                    OtherBuildItems =
                    {
                        new AndroidItem.AndroidAsset($"Assets\\{libName}.txt")
                        {
                            TextContent = () => "Asset1",
                            Encoding    = Encoding.ASCII,
                        },
                        new AndroidItem.AndroidAsset($"Assets\\subfolder\\{libName}.txt")
                        {
                            TextContent = () => "Asset2",
                            Encoding    = Encoding.ASCII,
                        },
                    },
                    Sources =
                    {
                        new BuildItem.Source($"{libName}.cs")
                        {
                            TextContent = () => @"using System;

namespace " + libName + @" {

	public class "     + libName + @" {
		public static void Foo () {
		}
	}
}"
                        },
                    }
                };
                var strings = lib.AndroidResources.First(x => x.Include() == "Resources\\values\\Strings.xml");
                strings.TextContent = () => @"<?xml version=""1.0"" encoding=""utf-8""?>
<resources>
	<string name="""     + libName + @"_name"">" + libName + @"</string>
</resources>";
                sb.Projects.Add(lib);
                app1.References.Add(new BuildItem.ProjectReference($"..\\{libName}\\{libName}.csproj", libName, lib.ProjectGuid));
                code.AppendLine($"\t\t\t{libName}.{libName}.Foo ();");
            }
            code.AppendLine("\t\t}");
            code.AppendLine("\t}");
            code.AppendLine("}");
            app1.Sources.Add(new BuildItem.Source("Code.cs")
            {
                TextContent = () => code.ToString(),
            });
            Assert.IsTrue(sb.Build(new string [] { "Configuration=Release" }), "Solution should have built.");
            Assert.IsTrue(sb.BuildProject(app1, "SignAndroidPackage"), "Build of project should have succeeded");
            sb.Dispose();
        }