public void Generate()
        {
            Context.Log($"Generating runners...");

            if (TargetFramework.IndexOf("-android", StringComparison.OrdinalIgnoreCase) != -1)
            {
                var code = GenerateAndroidSource();
                var name = "TestRunner.Android.sg.cs";

                AddSource(name, code);
            }
            else if (TargetFramework.IndexOf("-ios", StringComparison.OrdinalIgnoreCase) != -1)
            {
                var code = GenerateIosSource();
                var name = "TestRunner.iOS.sg.cs";

                AddSource(name, code);
            }
            else if (TargetFramework.IndexOf("-maccatalyst", StringComparison.OrdinalIgnoreCase) != -1)
            {
                var code = GenerateIosSource();
                var name = "TestRunner.MacCatalyst.sg.cs";

                AddSource(name, code);
            }
        }
Exemple #2
0
        /// <summary>
        /// 获得文件内容
        /// </summary>
        /// <param name="targetPath"></param>
        /// <returns></returns>
        private string GetFileContent(string targetPath)
        {
            string result = $"<Project Sdk=\"{Sdk}\">\r\n";

            result += "  <PropertyGroup>\r\n";
            result += $"    <TargetFramework>{TargetFramework}</TargetFramework>\r\n";
            if (TargetFramework.IndexOf("netcoreapp", StringComparison.Ordinal) > -1)
            {
                result += "    <AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>\r\n";
            }
            result += "  </PropertyGroup>\r\n";
            if (HasXmlFile)
            {
                result += "  <PropertyGroup  Condition=\"'$(Configuration)|$(Platform)' == 'Release|AnyCPU'\">\r\n";
                result += $"    <DocumentationFile>{Name}.xml</DocumentationFile>\r\n";
                result += "  </PropertyGroup>\r\n";
                result += "  <PropertyGroup  Condition=\"'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'\">\r\n";
                result += $"    <DocumentationFile>{Name}.xml</DocumentationFile>\r\n";
                result += "  </PropertyGroup>\r\n";
            }
            if (ItemGroups != null)
            {
                foreach (ItemGroupModel[] groups in ItemGroups)
                {
                    result += "  <ItemGroup>\r\n";
                    foreach (ItemGroupModel item in groups)
                    {
                        switch (item.Type)
                        {
                        case ItemGroupType.ProjectReference:
                            result += $"    <{item.Type.ToString()} Include=\"{item.Value}\" />\r\n";
                            break;

                        case ItemGroupType.Folder:
                            result += $"    <{item.Type.ToString()} Include=\"{item.Value}\" />\r\n";
                            Directory.CreateDirectory($"{targetPath}/{item.Value}");
                            break;

                        case ItemGroupType.PackageReference:
                            result += $"    <{item.Type.ToString()} Include=\"{item.Value}\" Version=\"{item.Version}\" />\r\n";
                            break;
                        }
                    }
                    result += "  </ItemGroup>\r\n";
                }
            }
            result += "</Project>";
            return(result);
        }